summaryrefslogtreecommitdiff
path: root/Command/Import.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-10-09 11:09:46 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-10-09 11:09:46 -0400
commit00ba3ec15d8e3a51545aed4c6e43771f2630a0f8 (patch)
treea6fa813ce14bb4ebbb40c7a58712c471ee880fcf /Command/Import.hs
parentbd0c751b267c080ba28a6efeb88b1c0af293429f (diff)
improve drop proof code
Diffstat (limited to 'Command/Import.hs')
-rw-r--r--Command/Import.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/Command/Import.hs b/Command/Import.hs
index 3206ad48b..f486da7c5 100644
--- a/Command/Import.hs
+++ b/Command/Import.hs
@@ -83,7 +83,7 @@ start mode (srcfile, destfile) =
where
deletedup k = do
showNote $ "duplicate of " ++ key2file k
- ifM (verifiedExisting k destfile)
+ verifyExisting k destfile
( do
liftIO $ removeFile srcfile
next $ return True
@@ -134,8 +134,8 @@ start mode (srcfile, destfile) =
SkipDuplicates -> checkdup Nothing (Just importfile)
_ -> return (Just importfile)
-verifiedExisting :: Key -> FilePath -> Annex Bool
-verifiedExisting key destfile = do
+verifyExisting :: Key -> FilePath -> (CommandPerform, CommandPerform) -> CommandPerform
+verifyExisting key destfile (yes, no) = do
-- Look up the numcopies setting for the file that it would be
-- imported to, if it were imported.
need <- getFileNumCopies destfile
@@ -143,4 +143,6 @@ verifiedExisting key destfile = do
(remotes, trusteduuids) <- knownCopies key
untrusteduuids <- trustGet UnTrusted
let tocheck = Remote.remotesWithoutUUID remotes (trusteduuids++untrusteduuids)
- verifyEnoughCopies [] key need [] (map (mkVerifiedCopy TrustedCopy) trusteduuids) tocheck
+ let preverified = map (mkVerifiedCopy TrustedCopy) trusteduuids
+ verifyEnoughCopiesToDrop [] key need [] preverified tocheck
+ (const yes) no