toward SafeDropProof expiry checking
Added Maybe POSIXTime to SafeDropProof, which gets set when the proof is based on a LockedCopy. If there are several LockedCopies, it uses the closest expiry time. That is not optimal, it may be that the proof expires based on one LockedCopy but another one has not expired. But that seems unlikely to really happen, and anyway the user can just re-run a drop if it fails due to expiry. Pass the SafeDropProof to removeKey, which is responsible for checking it for expiry in situations where that could be a problem. Which really only means in Remote.Git. Made Remote.Git check expiry when dropping from a local remote. Checking expiry when dropping from a P2P remote is not yet implemented. P2P.Protocol.remove has SafeDropProof plumbed through to it for that purpose. Fixing the remaining 2 build warnings should complete this work. Note that the use of a POSIXTime here means that if the clock gets set forward while git-annex is in the middle of a drop, it may say that dropping took too long. That seems ok. Less ok is that if the clock gets turned back a sufficient amount (eg 5 minutes), proof expiry won't be noticed. It might be better to use the Monotonic clock, but that doesn't advance when a laptop is suspended, and while there is the linux Boottime clock, that is not available on other systems. Perhaps a combination of POSIXTime and the Monotonic clock could detect laptop suspension and also detect clock being turned back? There is a potential future flag day where p2pDefaultLockContentRetentionDuration is not assumed, but is probed using the P2P protocol, and peers that don't support it can no longer produce a LockedCopy. Until that happens, when git-annex is communicating with older peers there is a risk of data loss when a ssh connection closes during LOCKCONTENT.
This commit is contained in:
parent
98dbfb6bbd
commit
1243af4a18
39 changed files with 274 additions and 123 deletions
|
@ -151,7 +151,7 @@ performRemote pcc key afile numcopies mincopies remote ud = do
|
|||
, "proof:"
|
||||
, show proof
|
||||
]
|
||||
ok <- Remote.action (Remote.removeKey remote key)
|
||||
ok <- Remote.action (Remote.removeKey remote proof key)
|
||||
next $ cleanupRemote key remote ud ok
|
||||
, stop
|
||||
)
|
||||
|
|
|
@ -639,7 +639,7 @@ badContentRemote remote localcopy key = do
|
|||
)
|
||||
)
|
||||
|
||||
dropped <- tryNonAsync (Remote.removeKey remote key)
|
||||
dropped <- tryNonAsync (Remote.removeKey remote Nothing key)
|
||||
when (isRight dropped) $
|
||||
Remote.logStatus remote key InfoMissing
|
||||
return $ case (movedbad, dropped) of
|
||||
|
|
|
@ -296,23 +296,26 @@ fromPerform' present updatelocationlog src key afile = do
|
|||
fromDrop :: Remote -> UUID -> DestStartedWithCopy -> Key -> AssociatedFile -> ([UnVerifiedCopy] -> [UnVerifiedCopy])-> CommandPerform
|
||||
fromDrop src destuuid deststartedwithcopy key afile adjusttocheck =
|
||||
willDropMakeItWorse (Remote.uuid src) destuuid deststartedwithcopy key afile >>= \case
|
||||
DropAllowed -> dropremote "moved"
|
||||
DropAllowed -> dropremote Nothing "moved"
|
||||
DropCheckNumCopies -> do
|
||||
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
||||
(tocheck, verified) <- verifiableCopies key [Remote.uuid src]
|
||||
verifyEnoughCopiesToDrop "" key (Just (Remote.uuid src)) Nothing numcopies mincopies [Remote.uuid src] verified
|
||||
(adjusttocheck tocheck) (dropremote . showproof) faileddropremote
|
||||
(adjusttocheck tocheck) dropremotewithproof faileddropremote
|
||||
DropWorse -> faileddropremote
|
||||
where
|
||||
showproof proof = "proof: " ++ show proof
|
||||
|
||||
dropremote reason = do
|
||||
dropremotewithproof proof =
|
||||
dropremote (Just proof) (showproof proof)
|
||||
|
||||
dropremote mproof reason = do
|
||||
fastDebug "Command.Move" $ unwords
|
||||
[ "Dropping from remote"
|
||||
, show src
|
||||
, "(" ++ reason ++ ")"
|
||||
]
|
||||
ok <- Remote.action (Remote.removeKey src key)
|
||||
ok <- Remote.action (Remote.removeKey src mproof key)
|
||||
when ok $
|
||||
logMoveCleanup deststartedwithcopy
|
||||
next $ Command.Drop.cleanupRemote key src (Command.Drop.DroppingUnused False) ok
|
||||
|
|
|
@ -303,7 +303,7 @@ test runannex mkr mkk =
|
|||
Right v -> return (True, v)
|
||||
Left _ -> return (False, UnVerified)
|
||||
store r k = Remote.storeKey r k (AssociatedFile Nothing) Nothing nullMeterUpdate
|
||||
remove r k = Remote.removeKey r k
|
||||
remove r k = Remote.removeKey r Nothing k
|
||||
|
||||
testExportTree :: RunAnnex -> Annex (Maybe Remote) -> Annex Key -> Annex Key -> [TestTree]
|
||||
testExportTree runannex mkr mkk1 mkk2 =
|
||||
|
@ -366,7 +366,7 @@ testExportTree runannex mkr mkk1 mkk2 =
|
|||
testUnavailable :: RunAnnex -> Annex (Maybe Remote) -> Annex Key -> [TestTree]
|
||||
testUnavailable runannex mkr mkk =
|
||||
[ check isLeft "removeKey" $ \r k ->
|
||||
Remote.removeKey r k
|
||||
Remote.removeKey r Nothing k
|
||||
, check isLeft "storeKey" $ \r k ->
|
||||
Remote.storeKey r k (AssociatedFile Nothing) Nothing nullMeterUpdate
|
||||
, check (`notElem` [Right True, Right False]) "checkPresent" $ \r k ->
|
||||
|
@ -397,7 +397,7 @@ cleanup :: [Remote] -> [Key] -> Bool -> CommandCleanup
|
|||
cleanup rs ks ok
|
||||
| all Remote.readonly rs = return ok
|
||||
| otherwise = do
|
||||
forM_ rs $ \r -> forM_ ks (Remote.removeKey r)
|
||||
forM_ rs $ \r -> forM_ ks (Remote.removeKey r Nothing)
|
||||
forM_ ks $ \k -> lockContentForRemoval k noop removeAnnex
|
||||
return ok
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue