diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-13 01:57:43 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-13 01:57:43 -0400 |
commit | 36f34c21f3dc8aa448f129e2a727381ca61c4c85 (patch) | |
tree | 34fc155b8289f80cab3c6eafcf933e5ab4fd12bc /Command | |
parent | 55de2b85f4e646e361d71e58f36d65b617c625e0 (diff) |
nice git ack space optimisation when setting the same metadata value for multiple files
Diffstat (limited to 'Command')
-rw-r--r-- | Command/MetaData.hs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Command/MetaData.hs b/Command/MetaData.hs index a645b274a..cc0364a30 100644 --- a/Command/MetaData.hs +++ b/Command/MetaData.hs @@ -14,6 +14,7 @@ import Logs.MetaData import Types.MetaData import qualified Data.Set as S +import Data.Time.Clock.POSIX def :: [Command] def = [withOptions [setOption] $ command "metadata" paramPaths seek @@ -30,19 +31,20 @@ setOption = Option ['s'] ["set"] (ReqArg mkmod "field[+-]=value") "set metadata" seek :: CommandSeek seek ps = do modmeta <- Annex.getState Annex.modmeta - withFilesInGit (whenAnnexed $ start modmeta) ps + now <- liftIO getPOSIXTime + withFilesInGit (whenAnnexed $ start now modmeta) ps -start :: [ModMeta] -> FilePath -> (Key, Backend) -> CommandStart -start ms file (k, _) = do +start :: POSIXTime -> [ModMeta] -> FilePath -> (Key, Backend) -> CommandStart +start now ms file (k, _) = do showStart "metadata" file - next $ perform k ms + next $ perform now ms k -perform :: Key -> [ModMeta] -> CommandPerform -perform k [] = next $ cleanup k -perform k ms = do +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 - addMetaData k m + addMetaData' k m now next $ cleanup k cleanup :: Key -> CommandCleanup |