diff options
author | Joey Hess <joey@kitenet.net> | 2011-08-06 14:57:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-08-06 14:57:22 -0400 |
commit | dede05171bc9431778da72e5e1235c69db9fa38e (patch) | |
tree | a9bc1f6fce6e16af835b9d3ff7d647ad0d82583e /Command/Add.hs | |
parent | dd8e649f49212c46df23f329299c64e13a3c90e1 (diff) |
addurl: --fast can be used to avoid immediately downloading the url.
The tricky part about this is that to generate a key, the file must be
present already. Worked around by adding (back) an URL key type, which
is used for addurl --fast.
Diffstat (limited to 'Command/Add.hs')
-rw-r--r-- | Command/Add.hs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Command/Add.hs b/Command/Add.hs index 58c0143dd..d8947fb07 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -8,6 +8,7 @@ module Command.Add where import Control.Monad.State (liftIO) +import Control.Monad (when) import System.Posix.Files import System.Directory import Control.Exception.Control (handle) @@ -52,7 +53,7 @@ perform (file, backend) = do Nothing -> stop Just (key, _) -> do handle (undo file key) $ moveAnnex key file - next $ cleanup file key + next $ cleanup file key True {- On error, put the file back so it doesn't seem to have vanished. - This can be called before or after the symlink is in place. -} @@ -72,18 +73,20 @@ undo file key e = do g <- Annex.gitRepo liftIO $ renameFile (gitAnnexLocation g key) file -cleanup :: FilePath -> Key -> CommandCleanup -cleanup file key = do +cleanup :: FilePath -> Key -> Bool -> CommandCleanup +cleanup file key hascontent = do handle (undo file key) $ do link <- calcGitLink file key liftIO $ createSymbolicLink link file - logStatus key InfoPresent + + when hascontent $ do + logStatus key InfoPresent - -- touch the symlink to have the same mtime as the - -- file it points to - s <- liftIO $ getFileStatus file - let mtime = modificationTime s - liftIO $ touch file (TimeSpec mtime) False + -- touch the symlink to have the same mtime as the + -- file it points to + s <- liftIO $ getFileStatus file + let mtime = modificationTime s + liftIO $ touch file (TimeSpec mtime) False force <- Annex.getState Annex.force if force |