diff options
author | 2014-02-23 00:08:29 -0400 | |
---|---|---|
committer | 2014-02-23 00:08:29 -0400 | |
commit | 704fa2fa789b453d354f2f375b0b42481c8990f6 (patch) | |
tree | afb28b2548c067be546b22fa6b04fa8b5d76c3fd /Command/Add.hs | |
parent | e0ae2f6bba897367ae23bfb1a6584ebd4843452e (diff) |
annex.genmetadata can be set to make git-annex automatically set metadata (year and month) when adding files
Diffstat (limited to 'Command/Add.hs')
-rw-r--r-- | Command/Add.hs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Command/Add.hs b/Command/Add.hs index d1dcb6025..0906ae531 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -19,6 +19,7 @@ import Annex.Content import Annex.Content.Direct import Annex.Perms import Annex.Link +import Annex.MetaData import qualified Annex import qualified Annex.Queue #ifdef WITH_CLIBS @@ -145,26 +146,32 @@ ingest Nothing = return (Nothing, Nothing) ingest (Just source) = do backend <- chooseBackend $ keyFilename source k <- genKey source backend - cache <- liftIO $ genInodeCache $ contentLocation source - case (cache, inodeCache source) of - (_, Nothing) -> go k cache - (Just newc, Just c) | compareStrong c newc -> go k cache + ms <- liftIO $ catchMaybeIO $ getFileStatus $ contentLocation source + let mcache = toInodeCache =<< ms + case (mcache, inodeCache source) of + (_, Nothing) -> go k mcache ms + (Just newc, Just c) | compareStrong c newc -> go k mcache ms _ -> failure "changed while it was being added" where - go k cache = ifM isDirect ( godirect k cache , goindirect k cache ) + go k mcache ms = ifM isDirect + ( godirect k mcache ms + , goindirect k mcache ms + ) - goindirect (Just (key, _)) mcache = do + goindirect (Just (key, _)) mcache ms = do catchAnnex (moveAnnex key $ contentLocation source) (undo (keyFilename source) key) + maybe noop (genMetaData key) ms liftIO $ nukeFile $ keyFilename source return $ (Just key, mcache) - goindirect Nothing _ = failure "failed to generate a key" + goindirect _ _ _ = failure "failed to generate a key" - godirect (Just (key, _)) (Just cache) = do + godirect (Just (key, _)) (Just cache) ms = do addInodeCache key cache + maybe noop (genMetaData key) ms finishIngestDirect key source return $ (Just key, Just cache) - godirect _ _ = failure "failed to generate a key" + godirect _ _ _ = failure "failed to generate a key" failure msg = do warning $ keyFilename source ++ " " ++ msg |