diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-24 14:41:33 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-24 14:41:33 -0400 |
commit | 820750d37839e72f449d364224d23f7035d23e2c (patch) | |
tree | 3d1f87db8f2b9e99e9a5cb4074e1f173d0fb2ee7 /Logs | |
parent | d56f245b212d6a9ec88ad9d69dee4f0cc22daa5d (diff) |
Preserve metadata when staging a new version of an annexed file.
Performance impact: When adding a large tree of new files, this needs
to do some git cat-file queries to check if any of the files already
existed and might need a metadata copy. I tried a benchmark in a copy
of my sound repository (so there was already a significant git tree
to check against.
Adding 10000 small files, with a cold cache:
before: 1m48.539s
after: 1m52.791s
So, impact is 0.0004 seconds per file added. Which seems acceptable, so did
not add some kind of configuration to enable/disable this.
This commit was sponsored by Lisa Feilen.
Diffstat (limited to 'Logs')
-rw-r--r-- | Logs/MetaData.hs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Logs/MetaData.hs b/Logs/MetaData.hs index 63314bcef..6702c3733 100644 --- a/Logs/MetaData.hs +++ b/Logs/MetaData.hs @@ -28,10 +28,10 @@ module Logs.MetaData ( getCurrentMetaData, - getMetaData, addMetaData, addMetaData', currentMetaData, + copyMetaData, ) where import Common.Annex @@ -135,3 +135,20 @@ simplifyLog s = case sl of where older = value l unique = older `differenceMetaData` newer + +{- Copies the metadata from the old key to the new key. + - + - The exact content of the metadata file is copied, so that the timestamps + - remain the same, and because this is more space-efficient in the git + - repository. + - + - Any metadata already attached to the new key is not preserved. + -} +copyMetaData :: Key -> Key -> Annex () +copyMetaData oldkey newkey + | oldkey == newkey = noop + | otherwise = do + l <- getMetaData oldkey + unless (S.null l) $ + Annex.Branch.change (metaDataLogFile newkey) $ + const $ showLog l |