diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-04-20 13:21:56 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-04-20 13:21:56 -0400 |
commit | 1f9967298f2bb98dd216c08ce049192737a1cf9f (patch) | |
tree | e6cb2e0141afefc28fefeabc58bc2ba9da9fbef8 /Annex | |
parent | 542461028d3700caded7c9940a4dde11f7e3f59a (diff) |
reinject: When src file's content cannot be verified, leave it alone, instead of deleting it.
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Content.hs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index c1d6031a7..36d9db7e9 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -18,8 +18,6 @@ module Annex.Content ( getViaTmp, getViaTmp', checkDiskSpaceToGet, - VerifyConfig(..), - Types.Remote.unVerified, prepTmp, withTmp, checkDiskSpace, @@ -45,6 +43,10 @@ module Annex.Content ( withObjectLoc, staleKeysPrune, isUnmodified, + verifyKeyContent, + VerifyConfig(..), + Verification(..), + unVerified, ) where import System.IO.Unsafe (unsafeInterleaveIO) @@ -71,6 +73,7 @@ import qualified Annex.Content.Direct as Direct import Annex.ReplaceFile import Annex.LockPool import Messages.Progress +import Types.Remote (unVerified, Verification(..)) import qualified Types.Remote import qualified Types.Backend import qualified Backend @@ -290,14 +293,14 @@ lockContentUsing locker key a = do {- Runs an action, passing it the temp file to get, - and if the action succeeds, verifies the file matches - the key and moves the file into the annex as a key's content. -} -getViaTmp :: VerifyConfig -> Key -> (FilePath -> Annex (Bool, Types.Remote.Verification)) -> Annex Bool +getViaTmp :: VerifyConfig -> Key -> (FilePath -> Annex (Bool, Verification)) -> Annex Bool getViaTmp v key action = checkDiskSpaceToGet key False $ getViaTmp' v key action {- Like getViaTmp, but does not check that there is enough disk space - for the incoming key. For use when the key content is already on disk - and not being copied into place. -} -getViaTmp' :: VerifyConfig -> Key -> (FilePath -> Annex (Bool, Types.Remote.Verification)) -> Annex Bool +getViaTmp' :: VerifyConfig -> Key -> (FilePath -> Annex (Bool, Verification)) -> Annex Bool getViaTmp' v key action = do tmpfile <- prepTmp key (ok, verification) <- action tmpfile @@ -325,9 +328,9 @@ getViaTmp' v key action = do - When the key's backend allows verifying the content (eg via checksum), - it is checked. -} -verifyKeyContent :: VerifyConfig -> Types.Remote.Verification -> Key -> FilePath -> Annex Bool -verifyKeyContent _ Types.Remote.Verified _ _ = return True -verifyKeyContent v Types.Remote.UnVerified k f = ifM (shouldVerify v) +verifyKeyContent :: VerifyConfig -> Verification -> Key -> FilePath -> Annex Bool +verifyKeyContent _ Verified _ _ = return True +verifyKeyContent v UnVerified k f = ifM (shouldVerify v) ( verifysize <&&> verifycontent , return True ) @@ -786,7 +789,7 @@ isUnmodified key f = go =<< geti go (Just fc) = cheapcheck fc <||> expensivecheck fc cheapcheck fc = anyM (compareInodeCaches fc) =<< Database.Keys.getInodeCaches key - expensivecheck fc = ifM (verifyKeyContent AlwaysVerify Types.Remote.UnVerified key f) + expensivecheck fc = ifM (verifyKeyContent AlwaysVerify UnVerified key f) -- The file could have been modified while it was -- being verified. Detect that. ( geti >>= maybe (return False) (compareInodeCaches fc) |