addurl: Bugfix: Did not properly add file in direct mode.
This commit is contained in:
parent
36913bc042
commit
7b4733f0e8
6 changed files with 49 additions and 31 deletions
|
@ -188,19 +188,29 @@ link file key hascontent = handle (undo file key) $ do
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
{- Note: Several other commands call this, and expect it to
|
{- Creates the symlink to the annexed content, and stages it in git.
|
||||||
- create the link and add it.
|
-
|
||||||
-
|
- As long as the filesystem supports symlinks, we use
|
||||||
- In direct mode, when we have the content of the file, it's left as-is,
|
|
||||||
- and we just stage a symlink to git.
|
|
||||||
-
|
|
||||||
- Otherwise, as long as the filesystem supports symlinks, we use
|
|
||||||
- git add, rather than directly staging the symlink to git.
|
- git add, rather than directly staging the symlink to git.
|
||||||
- Using git add is best because it allows the queuing to work
|
- Using git add is best because it allows the queuing to work
|
||||||
- and is faster (staging the symlink runs hash-object commands each time).
|
- and is faster (staging the symlink runs hash-object commands each time).
|
||||||
- Also, using git add allows it to skip gitignored files, unless forced
|
- Also, using git add allows it to skip gitignored files, unless forced
|
||||||
- to include them.
|
- to include them.
|
||||||
-}
|
-}
|
||||||
|
addLink :: FilePath -> Key -> Bool -> Annex ()
|
||||||
|
addLink file key hascontent = ifM (coreSymlinks <$> Annex.getGitConfig)
|
||||||
|
( do
|
||||||
|
_ <- link file key hascontent
|
||||||
|
params <- ifM (Annex.getState Annex.force)
|
||||||
|
( return [Param "-f"]
|
||||||
|
, return []
|
||||||
|
)
|
||||||
|
Annex.Queue.addCommand "add" (params++[Param "--"]) [file]
|
||||||
|
, do
|
||||||
|
l <- link file key hascontent
|
||||||
|
addAnnexLink l file
|
||||||
|
)
|
||||||
|
|
||||||
cleanup :: FilePath -> Key -> Bool -> CommandCleanup
|
cleanup :: FilePath -> Key -> Bool -> CommandCleanup
|
||||||
cleanup file key hascontent = do
|
cleanup file key hascontent = do
|
||||||
when hascontent $
|
when hascontent $
|
||||||
|
@ -209,17 +219,6 @@ cleanup file key hascontent = do
|
||||||
( do
|
( do
|
||||||
l <- inRepo $ gitAnnexLink file key
|
l <- inRepo $ gitAnnexLink file key
|
||||||
stageSymlink file =<< hashSymlink l
|
stageSymlink file =<< hashSymlink l
|
||||||
, ifM (coreSymlinks <$> Annex.getGitConfig)
|
, addLink file key hascontent
|
||||||
( do
|
|
||||||
_ <- link file key hascontent
|
|
||||||
params <- ifM (Annex.getState Annex.force)
|
|
||||||
( return [Param "-f"]
|
|
||||||
, return []
|
|
||||||
)
|
|
||||||
Annex.Queue.addCommand "add" (params++[Param "--"]) [file]
|
|
||||||
, do
|
|
||||||
l <- link file key hascontent
|
|
||||||
addAnnexLink l file
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Command.AddUnused where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import Logs.Unused
|
import Logs.Unused
|
||||||
|
import Logs.Location
|
||||||
import Command
|
import Command
|
||||||
import qualified Command.Add
|
import qualified Command.Add
|
||||||
import Types.Key
|
import Types.Key
|
||||||
|
@ -26,7 +27,10 @@ start = startUnused "addunused" perform
|
||||||
(performOther "tmp")
|
(performOther "tmp")
|
||||||
|
|
||||||
perform :: Key -> CommandPerform
|
perform :: Key -> CommandPerform
|
||||||
perform key = next $ Command.Add.cleanup file key True
|
perform key = next $ do
|
||||||
|
logStatus key InfoPresent
|
||||||
|
Command.Add.addLink file key False
|
||||||
|
return True
|
||||||
where
|
where
|
||||||
file = "unused." ++ key2file key
|
file = "unused." ++ key2file key
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import Command
|
||||||
import Backend
|
import Backend
|
||||||
import qualified Command.Add
|
import qualified Command.Add
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
import qualified Annex.Queue
|
||||||
import qualified Backend.URL
|
import qualified Backend.URL
|
||||||
import qualified Utility.Url as Url
|
import qualified Utility.Url as Url
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
|
@ -23,6 +24,7 @@ import Types.Key
|
||||||
import Types.KeySource
|
import Types.KeySource
|
||||||
import Config
|
import Config
|
||||||
import Annex.Content.Direct
|
import Annex.Content.Direct
|
||||||
|
import Logs.Location
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [notBareRepo $ withOptions [fileOption, pathdepthOption, relaxedOption] $
|
def = [notBareRepo $ withOptions [fileOption, pathdepthOption, relaxedOption] $
|
||||||
|
@ -92,12 +94,21 @@ download url file = do
|
||||||
k <- genKey source backend
|
k <- genKey source backend
|
||||||
case k of
|
case k of
|
||||||
Nothing -> stop
|
Nothing -> stop
|
||||||
Just (key, _) -> do
|
Just (key, _) -> next $ cleanup url file key (Just tmp)
|
||||||
whenM isDirect $
|
|
||||||
void $ addAssociatedFile key file
|
cleanup :: String -> FilePath -> Key -> Maybe FilePath -> CommandCleanup
|
||||||
moveAnnex key tmp
|
cleanup url file key mtmp = do
|
||||||
setUrlPresent key url
|
when (isJust mtmp) $
|
||||||
next $ Command.Add.cleanup file key True
|
logStatus key InfoPresent
|
||||||
|
setUrlPresent key url
|
||||||
|
Command.Add.addLink file key False
|
||||||
|
whenM isDirect $ do
|
||||||
|
void $ addAssociatedFile key file
|
||||||
|
{- For moveAnnex to work in direct mode, the symlink
|
||||||
|
- must already exist, so flush the queue. -}
|
||||||
|
Annex.Queue.flush
|
||||||
|
maybe noop (moveAnnex key) mtmp
|
||||||
|
return True
|
||||||
|
|
||||||
nodownload :: Bool -> String -> FilePath -> CommandPerform
|
nodownload :: Bool -> String -> FilePath -> CommandPerform
|
||||||
nodownload relaxed url file = do
|
nodownload relaxed url file = do
|
||||||
|
@ -108,10 +119,7 @@ nodownload relaxed url file = do
|
||||||
if exists
|
if exists
|
||||||
then do
|
then do
|
||||||
let key = Backend.URL.fromUrl url size
|
let key = Backend.URL.fromUrl url size
|
||||||
whenM isDirect $
|
next $ cleanup url file key Nothing
|
||||||
void $ addAssociatedFile key file
|
|
||||||
setUrlPresent key url
|
|
||||||
next $ Command.Add.cleanup file key False
|
|
||||||
else do
|
else do
|
||||||
warning $ "unable to access url: " ++ url
|
warning $ "unable to access url: " ++ url
|
||||||
stop
|
stop
|
||||||
|
|
|
@ -14,6 +14,7 @@ import Types.Key
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import qualified Command.Add
|
import qualified Command.Add
|
||||||
import Logs.Web
|
import Logs.Web
|
||||||
|
import Logs.Location
|
||||||
import Config
|
import Config
|
||||||
import Utility.CopyFile
|
import Utility.CopyFile
|
||||||
|
|
||||||
|
@ -70,4 +71,6 @@ cleanup file oldkey newkey = do
|
||||||
|
|
||||||
-- Update symlink to use the new key.
|
-- Update symlink to use the new key.
|
||||||
liftIO $ removeFile file
|
liftIO $ removeFile file
|
||||||
Command.Add.cleanup file newkey True
|
Command.Add.addLink file newkey True
|
||||||
|
logStatus newkey InfoPresent
|
||||||
|
return True
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -6,6 +6,7 @@ git-annex (4.20130406) UNRELEASED; urgency=low
|
||||||
remotes, to avoid delays.
|
remotes, to avoid delays.
|
||||||
Thanks, guilhem for the patch.
|
Thanks, guilhem for the patch.
|
||||||
* Bugfix: Direct mode no longer repeatedly checksums duplicated files.
|
* Bugfix: Direct mode no longer repeatedly checksums duplicated files.
|
||||||
|
* addurl: Bugfix: Did not properly add file in direct mode.
|
||||||
* Adjust preferred content expressions so that content in archive
|
* Adjust preferred content expressions so that content in archive
|
||||||
directories is preferred until it has reached an archive or smallarchive
|
directories is preferred until it has reached an archive or smallarchive
|
||||||
repository.
|
repository.
|
||||||
|
|
|
@ -69,3 +69,6 @@ Please provide any additional information below.
|
||||||
The repository in question was created by the assistant and I tried the above with the assistant both running and not running, with no difference. I have also tried downloading other files.
|
The repository in question was created by the assistant and I tried the above with the assistant both running and not running, with no difference. I have also tried downloading other files.
|
||||||
|
|
||||||
EDIT: formatting
|
EDIT: formatting
|
||||||
|
|
||||||
|
> Bug only affected direct mode. I think it used to work but I broke
|
||||||
|
> it when fixing another bug in direct mode. [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue