diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-01-07 17:39:59 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-01-07 17:48:04 -0400 |
commit | baa5f0ff25f3a3833c46b1e0d60242bd9066eaae (patch) | |
tree | 7f32eb02c862c5064fe8b71b1c7cffe96ea34998 /Annex | |
parent | a3a92b330d11737fbc46a5af4ed16190f4291d7c (diff) |
avoid confusing git with a modified ctime in clean filter
Linking the file to the tmp dir was not necessary in the clean
filter, and it caused the ctime to change, which caused git to think
the file was changed. This caused git status to get slow as it kept
re-cleaning unchanged files.
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Ingest.hs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/Annex/Ingest.hs b/Annex/Ingest.hs index 73f8a39ca..70ea105bb 100644 --- a/Annex/Ingest.hs +++ b/Annex/Ingest.hs @@ -9,6 +9,7 @@ module Annex.Ingest ( LockedDown(..), + LockDownConfig(..), lockDown, ingest, finishIngestDirect, @@ -48,11 +49,17 @@ import Utility.Touch import Control.Exception (IOException) data LockedDown = LockedDown - { lockingFile :: Bool + { lockDownConfig :: LockDownConfig , keySource :: KeySource } deriving (Show) +data LockDownConfig = LockDownConfig + { lockingFile :: Bool -- ^ write bit removed during lock down + , hardlinkFileTmp :: Bool -- ^ hard link to temp directory + } + deriving (Show) + {- The file that's being ingested is locked down before a key is generated, - to prevent it from being modified in between. This lock down is not - perfect at best (and pretty weak at worst). For example, it does not @@ -64,24 +71,21 @@ data LockedDown = LockedDown - against some changes, like deletion or overwrite of the file, and - allows lsof checks to be done more efficiently when adding a lot of files. - - - If lockingfile is True, the file is going to be added in locked mode. - - So, its write bit is removed as part of the lock down. - - - Lockdown can fail if a file gets deleted, and Nothing will be returned. -} -lockDown :: Bool -> FilePath -> Annex (Maybe LockedDown) -lockDown lockingfile file = either +lockDown :: LockDownConfig -> FilePath -> Annex (Maybe LockedDown) +lockDown cfg file = either (\e -> warning (show e) >> return Nothing) (return . Just) - =<< lockDown' lockingfile file + =<< lockDown' cfg file -lockDown' :: Bool -> FilePath -> Annex (Either IOException LockedDown) -lockDown' lockingfile file = ifM crippledFileSystem +lockDown' :: LockDownConfig -> FilePath -> Annex (Either IOException LockedDown) +lockDown' cfg file = ifM (pure (not (hardlinkFileTmp cfg)) <||> crippledFileSystem) ( withTSDelta $ liftIO . tryIO . nohardlink , tryIO $ do tmp <- fromRepo gitAnnexTmpMiscDir createAnnexDirectory tmp - when lockingfile $ + when (lockingFile cfg) $ freezeContent file withTSDelta $ \delta -> liftIO $ do (tmpfile, h) <- openTempFile tmp $ @@ -93,7 +97,7 @@ lockDown' lockingfile file = ifM crippledFileSystem where nohardlink delta = do cache <- genInodeCache file delta - return $ LockedDown lockingfile $ KeySource + return $ LockedDown cfg $ KeySource { keyFilename = file , contentLocation = file , inodeCache = cache @@ -101,7 +105,7 @@ lockDown' lockingfile file = ifM crippledFileSystem withhardlink delta tmpfile = do createLink file tmpfile cache <- genInodeCache tmpfile delta - return $ LockedDown lockingfile $ KeySource + return $ LockedDown cfg $ KeySource { keyFilename = file , contentLocation = tmpfile , inodeCache = cache @@ -115,7 +119,7 @@ lockDown' lockingfile file = ifM crippledFileSystem -} ingest :: Maybe LockedDown -> Annex (Maybe Key, Maybe InodeCache) ingest Nothing = return (Nothing, Nothing) -ingest (Just (LockedDown lockingfile source)) = withTSDelta $ \delta -> do +ingest (Just (LockedDown cfg source)) = withTSDelta $ \delta -> do backend <- chooseBackend $ keyFilename source k <- genKey source backend let src = contentLocation source @@ -127,7 +131,7 @@ ingest (Just (LockedDown lockingfile source)) = withTSDelta $ \delta -> do _ -> failure "changed while it was being added" where go (Just (key, _)) mcache (Just s) - | lockingfile = golocked key mcache s + | lockingFile cfg = golocked key mcache s | otherwise = ifM isDirect ( godirect key mcache s , gounlocked key mcache s |