verify local copy of content with locking

This commit is contained in:
Joey Hess 2015-10-09 14:57:32 -04:00
parent a5e74e9e64
commit 45e1a7c361
Failed to extract signature
4 changed files with 93 additions and 86 deletions

View file

@ -97,12 +97,9 @@ startRemote afile numcopies key remote = do
-- sees the key is present on the other.
performLocal :: Key -> AssociatedFile -> NumCopies -> [VerifiedCopy] -> CommandPerform
performLocal key afile numcopies preverified = lockContentExclusive key $ \contentlock -> do
(remotes, trusteduuids) <- Remote.keyPossibilitiesTrusted key
let preverified' = preverified ++ map (mkVerifiedCopy TrustedCopy) trusteduuids
untrusteduuids <- trustGet UnTrusted
let tocheck = Remote.remotesWithoutUUID remotes (map toUUID preverified'++untrusteduuids)
u <- getUUID
doDrop u key afile numcopies [] preverified' tocheck
(tocheck, verified) <- verifiableCopies key [u]
doDrop u key afile numcopies [] (preverified ++ verified) tocheck
( \proof -> do
liftIO $ debugM "drop" $ unwords
[ "Dropping from here"
@ -123,13 +120,8 @@ performRemote key afile numcopies remote = do
-- places assumed to have the key, and places to check.
-- When the local repo has the key, that's one additional copy,
-- as long as the local repo is not untrusted.
(remotes, trusteduuids) <- knownCopies key
let trusted = filter (/= uuid) trusteduuids
let preverified = map (mkVerifiedCopy TrustedCopy) trusted
untrusteduuids <- trustGet UnTrusted
let tocheck = filter (/= remote) $
Remote.remotesWithoutUUID remotes (trusted++untrusteduuids)
doDrop uuid key afile numcopies [uuid] preverified tocheck
(tocheck, verified) <- verifiableCopies key [uuid]
doDrop uuid key afile numcopies [uuid] verified tocheck
( \proof -> do
liftIO $ debugM "drop" $ unwords
[ "Dropping from remote"
@ -165,7 +157,16 @@ cleanupRemote key remote ok = do
-
- --force overrides and always allows dropping.
-}
doDrop :: UUID -> Key -> AssociatedFile -> NumCopies -> [UUID] -> [VerifiedCopy] -> [Remote] -> (Maybe SafeDropProof -> CommandPerform, CommandPerform) -> CommandPerform
doDrop
:: UUID
-> Key
-> AssociatedFile
-> NumCopies
-> [UUID]
-> [VerifiedCopy]
-> [UnVerifiedCopy]
-> (Maybe SafeDropProof -> CommandPerform, CommandPerform)
-> CommandPerform
doDrop dropfrom key afile numcopies skip preverified check (dropaction, nodropaction) =
ifM (Annex.getState Annex.force)
( dropaction Nothing

View file

@ -140,9 +140,6 @@ verifyExisting key destfile (yes, no) = do
-- imported to, if it were imported.
need <- getFileNumCopies destfile
(remotes, trusteduuids) <- knownCopies key
untrusteduuids <- trustGet UnTrusted
let tocheck = Remote.remotesWithoutUUID remotes (trusteduuids++untrusteduuids)
let preverified = map (mkVerifiedCopy TrustedCopy) trusteduuids
(tocheck, preverified) <- verifiableCopies key []
verifyEnoughCopiesToDrop [] key need [] preverified tocheck
(const yes) no