plumb in LiveUpdate (WIP)
Each command that first checks preferred content (and/or required content) and then does something that can change the sizes of repositories needs to call prepareLiveUpdate, and plumb it through the preferred content check and the location log update. So far, only Command.Drop is done. Many other commands that don't need to do this have been updated to keep working. There may be some calls to NoLiveUpdate in places where that should be done. All will need to be double checked. Not currently in a compilable state.
This commit is contained in:
parent
4885073377
commit
c3d40b9ec3
58 changed files with 363 additions and 247 deletions
|
@ -83,15 +83,17 @@ start o from si file key = start' o from key afile ai si
|
|||
ai = mkActionItem (key, afile)
|
||||
|
||||
start' :: DropOptions -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> SeekInput -> CommandStart
|
||||
start' o from key afile ai si =
|
||||
checkDropAuto (autoMode o) from afile key $ \numcopies mincopies ->
|
||||
stopUnless wantdrop $
|
||||
start' o from key afile ai si = do
|
||||
checkDropAuto (autoMode o) from afile key $ \numcopies mincopies -> do
|
||||
lu <- prepareLiveUpdate remoteuuid key RemovingKey
|
||||
stopUnless (wantdrop lu) $
|
||||
case from of
|
||||
Nothing -> startLocal pcc afile ai si numcopies mincopies key [] ud
|
||||
Just remote -> startRemote pcc afile ai si numcopies mincopies key ud remote
|
||||
Nothing -> startLocal lu pcc afile ai si numcopies mincopies key [] ud
|
||||
Just remote -> startRemote lu pcc afile ai si numcopies mincopies key ud remote
|
||||
where
|
||||
wantdrop
|
||||
| autoMode o = wantDrop False (Remote.uuid <$> from) (Just key) afile Nothing
|
||||
remoteuuid = Remote.uuid <$> from
|
||||
wantdrop lu
|
||||
| autoMode o = wantDrop lu False remoteuuid (Just key) afile Nothing
|
||||
| otherwise = return True
|
||||
pcc = PreferredContentChecked (autoMode o)
|
||||
ud = case (batchOption o, keyOptions o) of
|
||||
|
@ -101,22 +103,22 @@ start' o from key afile ai si =
|
|||
startKeys :: DropOptions -> Maybe Remote -> (SeekInput, Key, ActionItem) -> CommandStart
|
||||
startKeys o from (si, key, ai) = start' o from key (AssociatedFile Nothing) ai si
|
||||
|
||||
startLocal :: PreferredContentChecked -> AssociatedFile -> ActionItem -> SeekInput -> NumCopies -> MinCopies -> Key -> [VerifiedCopy] -> DroppingUnused -> CommandStart
|
||||
startLocal pcc afile ai si numcopies mincopies key preverified ud =
|
||||
startLocal :: LiveUpdate -> PreferredContentChecked -> AssociatedFile -> ActionItem -> SeekInput -> NumCopies -> MinCopies -> Key -> [VerifiedCopy] -> DroppingUnused -> CommandStart
|
||||
startLocal lu pcc afile ai si numcopies mincopies key preverified ud =
|
||||
starting "drop" (OnlyActionOn key ai) si $
|
||||
performLocal pcc key afile numcopies mincopies preverified ud
|
||||
performLocal lu pcc key afile numcopies mincopies preverified ud
|
||||
|
||||
startRemote :: PreferredContentChecked -> AssociatedFile -> ActionItem -> SeekInput -> NumCopies -> MinCopies -> Key -> DroppingUnused -> Remote -> CommandStart
|
||||
startRemote pcc afile ai si numcopies mincopies key ud remote =
|
||||
startRemote :: LiveUpdate -> PreferredContentChecked -> AssociatedFile -> ActionItem -> SeekInput -> NumCopies -> MinCopies -> Key -> DroppingUnused -> Remote -> CommandStart
|
||||
startRemote lu pcc afile ai si numcopies mincopies key ud remote =
|
||||
starting "drop" (OnlyActionOn key ai) si $ do
|
||||
showAction $ UnquotedString $ "from " ++ Remote.name remote
|
||||
performRemote pcc key afile numcopies mincopies remote ud
|
||||
performRemote lu pcc key afile numcopies mincopies remote ud
|
||||
|
||||
performLocal :: PreferredContentChecked -> Key -> AssociatedFile -> NumCopies -> MinCopies -> [VerifiedCopy] -> DroppingUnused -> CommandPerform
|
||||
performLocal pcc key afile numcopies mincopies preverified ud = lockContentForRemoval key fallback $ \contentlock -> do
|
||||
performLocal :: LiveUpdate -> PreferredContentChecked -> Key -> AssociatedFile -> NumCopies -> MinCopies -> [VerifiedCopy] -> DroppingUnused -> CommandPerform
|
||||
performLocal lu pcc key afile numcopies mincopies preverified ud = lockContentForRemoval key fallback $ \contentlock -> do
|
||||
u <- getUUID
|
||||
(tocheck, verified) <- verifiableCopies key [u]
|
||||
doDrop pcc u (Just contentlock) key afile numcopies mincopies [] (preverified ++ verified) tocheck
|
||||
doDrop lu pcc u (Just contentlock) key afile numcopies mincopies [] (preverified ++ verified) tocheck
|
||||
( \proof -> do
|
||||
fastDebug "Command.Drop" $ unwords
|
||||
[ "Dropping from here"
|
||||
|
@ -125,7 +127,7 @@ performLocal pcc key afile numcopies mincopies preverified ud = lockContentForRe
|
|||
]
|
||||
removeAnnex contentlock
|
||||
notifyDrop afile True
|
||||
next $ cleanupLocal key ud
|
||||
next $ cleanupLocal lu key ud
|
||||
, do
|
||||
notifyDrop afile False
|
||||
stop
|
||||
|
@ -136,14 +138,14 @@ performLocal pcc key afile numcopies mincopies preverified ud = lockContentForRe
|
|||
-- is present, but due to buffering, may find it present for the
|
||||
-- second file before the first is dropped. If so, nothing remains
|
||||
-- to be done except for cleaning up.
|
||||
fallback = next $ cleanupLocal key ud
|
||||
fallback = next $ cleanupLocal lu key ud
|
||||
|
||||
performRemote :: PreferredContentChecked -> Key -> AssociatedFile -> NumCopies -> MinCopies -> Remote -> DroppingUnused -> CommandPerform
|
||||
performRemote pcc key afile numcopies mincopies remote ud = do
|
||||
performRemote :: LiveUpdate -> PreferredContentChecked -> Key -> AssociatedFile -> NumCopies -> MinCopies -> Remote -> DroppingUnused -> CommandPerform
|
||||
performRemote lu pcc key afile numcopies mincopies remote ud = do
|
||||
-- Filter the uuid it's being dropped from out of the lists of
|
||||
-- places assumed to have the key, and places to check.
|
||||
(tocheck, verified) <- verifiableCopies key [uuid]
|
||||
doDrop pcc uuid Nothing key afile numcopies mincopies [uuid] verified tocheck
|
||||
doDrop lu pcc uuid Nothing key afile numcopies mincopies [uuid] verified tocheck
|
||||
( \proof -> do
|
||||
fastDebug "Command.Drop" $ unwords
|
||||
[ "Dropping from remote"
|
||||
|
@ -152,21 +154,21 @@ performRemote pcc key afile numcopies mincopies remote ud = do
|
|||
, show proof
|
||||
]
|
||||
ok <- Remote.action (Remote.removeKey remote proof key)
|
||||
next $ cleanupRemote key remote ud ok
|
||||
next $ cleanupRemote lu key remote ud ok
|
||||
, stop
|
||||
)
|
||||
where
|
||||
uuid = Remote.uuid remote
|
||||
|
||||
cleanupLocal :: Key -> DroppingUnused -> CommandCleanup
|
||||
cleanupLocal key ud = do
|
||||
logStatus key (dropStatus ud)
|
||||
cleanupLocal :: LiveUpdate -> Key -> DroppingUnused -> CommandCleanup
|
||||
cleanupLocal lu key ud = do
|
||||
logStatus lu key (dropStatus ud)
|
||||
return True
|
||||
|
||||
cleanupRemote :: Key -> Remote -> DroppingUnused -> Bool -> CommandCleanup
|
||||
cleanupRemote key remote ud ok = do
|
||||
cleanupRemote :: LiveUpdate -> Key -> Remote -> DroppingUnused -> Bool -> CommandCleanup
|
||||
cleanupRemote lu key remote ud ok = do
|
||||
when ok $
|
||||
Remote.logStatus remote key (dropStatus ud)
|
||||
Remote.logStatus lu remote key (dropStatus ud)
|
||||
return ok
|
||||
|
||||
{- Set when the user explicitly chose to operate on unused content.
|
||||
|
@ -189,7 +191,8 @@ dropStatus (DroppingUnused True) = InfoDead
|
|||
- --force overrides and always allows dropping.
|
||||
-}
|
||||
doDrop
|
||||
:: PreferredContentChecked
|
||||
:: LiveUpdate
|
||||
-> PreferredContentChecked
|
||||
-> UUID
|
||||
-> Maybe ContentRemovalLock
|
||||
-> Key
|
||||
|
@ -201,10 +204,10 @@ doDrop
|
|||
-> [UnVerifiedCopy]
|
||||
-> (Maybe SafeDropProof -> CommandPerform, CommandPerform)
|
||||
-> CommandPerform
|
||||
doDrop pcc dropfrom contentlock key afile numcopies mincopies skip preverified check (dropaction, nodropaction) =
|
||||
doDrop lu pcc dropfrom contentlock key afile numcopies mincopies skip preverified check (dropaction, nodropaction) =
|
||||
ifM (Annex.getRead Annex.force)
|
||||
( dropaction Nothing
|
||||
, ifM (checkRequiredContent pcc dropfrom key afile)
|
||||
, ifM (checkRequiredContent lu pcc dropfrom key afile)
|
||||
( verifyEnoughCopiesToDrop nolocmsg key (Just dropfrom)
|
||||
contentlock numcopies mincopies
|
||||
skip preverified check
|
||||
|
@ -225,10 +228,10 @@ doDrop pcc dropfrom contentlock key afile numcopies mincopies skip preverified c
|
|||
- providing this avoids that extra work. -}
|
||||
newtype PreferredContentChecked = PreferredContentChecked Bool
|
||||
|
||||
checkRequiredContent :: PreferredContentChecked -> UUID -> Key -> AssociatedFile -> Annex Bool
|
||||
checkRequiredContent (PreferredContentChecked True) _ _ _ = return True
|
||||
checkRequiredContent (PreferredContentChecked False) u k afile =
|
||||
checkDrop isRequiredContent False (Just u) (Just k) afile Nothing >>= \case
|
||||
checkRequiredContent :: LiveUpdate -> PreferredContentChecked -> UUID -> Key -> AssociatedFile -> Annex Bool
|
||||
checkRequiredContent _ (PreferredContentChecked True) _ _ _ = return True
|
||||
checkRequiredContent lu (PreferredContentChecked False) u k afile =
|
||||
checkDrop isRequiredContent lu False (Just u) (Just k) afile Nothing >>= \case
|
||||
Nothing -> return True
|
||||
Just afile' -> do
|
||||
if afile == afile'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue