summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-04-20 13:21:56 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-04-20 13:21:56 -0400
commit1f9967298f2bb98dd216c08ce049192737a1cf9f (patch)
treee6cb2e0141afefc28fefeabc58bc2ba9da9fbef8 /Command
parent542461028d3700caded7c9940a4dde11f7e3f59a (diff)
reinject: When src file's content cannot be verified, leave it alone, instead of deleting it.
Diffstat (limited to 'Command')
-rw-r--r--Command/Reinject.hs15
-rw-r--r--Command/TestRemote.hs6
2 files changed, 10 insertions, 11 deletions
diff --git a/Command/Reinject.hs b/Command/Reinject.hs
index d50db18af..0b1b0e2e2 100644
--- a/Command/Reinject.hs
+++ b/Command/Reinject.hs
@@ -38,14 +38,13 @@ perform src _dest key = ifM move
, error "failed"
)
where
- -- The file might be on a different filesystem,
- -- so moveFile is used rather than simply calling
- -- moveToObjectDir; disk space is also checked this way,
- -- and the file's content is verified to match the key.
- move = getViaTmp DefaultVerify key $ \tmp -> unVerified $
- liftIO $ catchBoolIO $ do
- moveFile src tmp
- return True
+ move = checkDiskSpaceToGet key False $
+ ifM (verifyKeyContent DefaultVerify UnVerified key src)
+ ( do
+ moveAnnex key src
+ return True
+ , return False
+ )
cleanup :: Key -> CommandCleanup
cleanup key = do
diff --git a/Command/TestRemote.hs b/Command/TestRemote.hs
index 5c5d62e1d..40d02c166 100644
--- a/Command/TestRemote.hs
+++ b/Command/TestRemote.hs
@@ -11,7 +11,7 @@ import Command
import qualified Annex
import qualified Remote
import qualified Types.Remote as Remote
-import Types.Backend (getKey, verifyKeyContent)
+import qualified Types.Backend as Backend
import Types.KeySource
import Annex.Content
import Backend
@@ -151,7 +151,7 @@ test st r k =
(== Right b) <$> Remote.hasKey r k
fsck = case maybeLookupBackendName (keyBackendName k) of
Nothing -> return True
- Just b -> case verifyKeyContent b of
+ Just b -> case Backend.verifyKeyContent b of
Nothing -> return True
Just verifier -> verifier k (key2file k)
get = getViaTmp (RemoteVerify r) k $ \dest ->
@@ -224,6 +224,6 @@ randKey sz = withTmpFile "randkey" $ \f h -> do
, inodeCache = Nothing
}
k <- fromMaybe (error "failed to generate random key")
- <$> getKey Backend.Hash.testKeyBackend ks
+ <$> Backend.getKey Backend.Hash.testKeyBackend ks
moveAnnex k f
return k