diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-23 00:08:29 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-23 00:08:29 -0400 |
commit | 704fa2fa789b453d354f2f375b0b42481c8990f6 (patch) | |
tree | afb28b2548c067be546b22fa6b04fa8b5d76c3fd /Command | |
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')
-rw-r--r-- | Command/Add.hs | 25 | ||||
-rw-r--r-- | Command/MetaData.hs | 3 | ||||
-rw-r--r-- | Command/View.hs | 1 |
3 files changed, 19 insertions, 10 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 diff --git a/Command/MetaData.hs b/Command/MetaData.hs index 6112dd095..651cb4944 100644 --- a/Command/MetaData.hs +++ b/Command/MetaData.hs @@ -10,6 +10,7 @@ module Command.MetaData where import Common.Annex import qualified Annex import Command +import Annex.MetaData import Logs.MetaData import Types.MetaData @@ -55,7 +56,7 @@ perform :: POSIXTime -> [ModMeta] -> Key -> CommandPerform perform _ [] k = next $ cleanup k perform now ms k = do oldm <- getCurrentMetaData k - let m = foldl' unionMetaData newMetaData $ map (modMeta oldm) ms + let m = foldl' unionMetaData emptyMetaData $ map (modMeta oldm) ms addMetaData' k m now next $ cleanup k diff --git a/Command/View.hs b/Command/View.hs index f123e3812..e5182e852 100644 --- a/Command/View.hs +++ b/Command/View.hs @@ -14,6 +14,7 @@ import qualified Git.Command import qualified Git.Ref import qualified Git.Branch import Types.MetaData +import Annex.MetaData import Types.View import Annex.View import Logs.View |