plumb in LiveUpdate to copy/get/move/mirror
copy and get do check preferred content, so need to prepareLiveUpdate. move and mirror do not, but copy is implemented using move, so move also needed to have a LiveUpdate plumbed through.
This commit is contained in:
parent
418fbf3f2f
commit
eb841ab004
4 changed files with 110 additions and 90 deletions
|
@ -72,14 +72,27 @@ seek' o fto = startConcurrency (Command.Move.stages fto) $ do
|
||||||
FromAnywhereToRemote _ -> Nothing
|
FromAnywhereToRemote _ -> Nothing
|
||||||
, usesLocationLog = True
|
, usesLocationLog = True
|
||||||
}
|
}
|
||||||
keyaction = Command.Move.startKey fto Command.Move.RemoveNever
|
keyaction = Command.Move.startKey NoLiveUpdate fto Command.Move.RemoveNever
|
||||||
|
|
||||||
{- A copy is just a move that does not delete the source file.
|
{- A copy is just a move that does not delete the source file.
|
||||||
- However, auto mode avoids unnecessary copies, and avoids getting or
|
- However, auto mode avoids unnecessary copies, and avoids getting or
|
||||||
- sending non-preferred content. -}
|
- sending non-preferred content. -}
|
||||||
start :: CopyOptions -> FromToHereOptions -> SeekInput -> RawFilePath -> Key -> CommandStart
|
start :: CopyOptions -> FromToHereOptions -> SeekInput -> RawFilePath -> Key -> CommandStart
|
||||||
start o fto si file key = stopUnless shouldCopy $
|
start o fto si file key = do
|
||||||
Command.Move.start fto Command.Move.RemoveNever si file key
|
ru <- case fto of
|
||||||
|
FromOrToRemote (ToRemote dest) -> getru dest
|
||||||
|
FromOrToRemote (FromRemote _) -> pure Nothing
|
||||||
|
ToHere -> pure Nothing
|
||||||
|
FromRemoteToRemote _ dest -> getru dest
|
||||||
|
FromAnywhereToRemote dest -> getru dest
|
||||||
|
lu <- prepareLiveUpdate ru key AddingKey
|
||||||
|
start' lu o fto si file key
|
||||||
|
where
|
||||||
|
getru dest = Just . Remote.uuid <$> getParsed dest
|
||||||
|
|
||||||
|
start' :: LiveUpdate -> CopyOptions -> FromToHereOptions -> SeekInput -> RawFilePath -> Key -> CommandStart
|
||||||
|
start' lu o fto si file key = stopUnless shouldCopy $
|
||||||
|
Command.Move.start lu fto Command.Move.RemoveNever si file key
|
||||||
where
|
where
|
||||||
shouldCopy
|
shouldCopy
|
||||||
| autoMode o = want <||> numCopiesCheck file key (<)
|
| autoMode o = want <||> numCopiesCheck file key (<)
|
||||||
|
@ -93,5 +106,5 @@ start o fto si file key = stopUnless shouldCopy $
|
||||||
|
|
||||||
checkwantsend dest =
|
checkwantsend dest =
|
||||||
(Remote.uuid <$> getParsed dest) >>=
|
(Remote.uuid <$> getParsed dest) >>=
|
||||||
wantGetBy False (Just key) (AssociatedFile (Just file))
|
wantGetBy lu False (Just key) (AssociatedFile (Just file))
|
||||||
checkwantget = wantGet False (Just key) (AssociatedFile (Just file))
|
checkwantget = wantGet lu False (Just key) (AssociatedFile (Just file))
|
||||||
|
|
|
@ -56,42 +56,44 @@ seek o = startConcurrency transferStages $ do
|
||||||
ww = WarnUnmatchLsFiles "get"
|
ww = WarnUnmatchLsFiles "get"
|
||||||
|
|
||||||
start :: GetOptions -> Maybe Remote -> SeekInput -> RawFilePath -> Key -> CommandStart
|
start :: GetOptions -> Maybe Remote -> SeekInput -> RawFilePath -> Key -> CommandStart
|
||||||
start o from si file key = start' expensivecheck from key afile ai si
|
start o from si file key = do
|
||||||
|
lu <- prepareLiveUpdate Nothing key AddingKey
|
||||||
|
start' lu (expensivecheck lu) from key afile ai si
|
||||||
where
|
where
|
||||||
afile = AssociatedFile (Just file)
|
afile = AssociatedFile (Just file)
|
||||||
ai = mkActionItem (key, afile)
|
ai = mkActionItem (key, afile)
|
||||||
expensivecheck
|
expensivecheck lu
|
||||||
| autoMode o = numCopiesCheck file key (<)
|
| autoMode o = numCopiesCheck file key (<)
|
||||||
<||> wantGet False (Just key) afile
|
<||> wantGet lu False (Just key) afile
|
||||||
| otherwise = return True
|
| otherwise = return True
|
||||||
|
|
||||||
startKeys :: Maybe Remote -> (SeekInput, Key, ActionItem) -> CommandStart
|
startKeys :: Maybe Remote -> (SeekInput, Key, ActionItem) -> CommandStart
|
||||||
startKeys from (si, key, ai) = checkFailedTransferDirection ai Download $
|
startKeys from (si, key, ai) = checkFailedTransferDirection ai Download $
|
||||||
start' (return True) from key (AssociatedFile Nothing) ai si
|
start' NoLiveUpdate (return True) from key (AssociatedFile Nothing) ai si
|
||||||
|
|
||||||
start' :: Annex Bool -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> SeekInput -> CommandStart
|
start' :: LiveUpdate -> Annex Bool -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> SeekInput -> CommandStart
|
||||||
start' expensivecheck from key afile ai si =
|
start' lu expensivecheck from key afile ai si =
|
||||||
stopUnless expensivecheck $
|
stopUnless expensivecheck $
|
||||||
case from of
|
case from of
|
||||||
Nothing -> go $ perform key afile
|
Nothing -> go $ perform lu key afile
|
||||||
Just src ->
|
Just src ->
|
||||||
stopUnless (Command.Move.fromOk src key) $
|
stopUnless (Command.Move.fromOk src key) $
|
||||||
go $ Command.Move.fromPerform src Command.Move.RemoveNever key afile
|
go $ Command.Move.fromPerform lu src Command.Move.RemoveNever key afile
|
||||||
where
|
where
|
||||||
go = starting "get" (OnlyActionOn key ai) si
|
go = starting "get" (OnlyActionOn key ai) si
|
||||||
|
|
||||||
perform :: Key -> AssociatedFile -> CommandPerform
|
perform :: LiveUpdate -> Key -> AssociatedFile -> CommandPerform
|
||||||
perform key afile = stopUnless (getKey key afile) $
|
perform lu key afile = stopUnless (getKey lu key afile) $
|
||||||
next $ return True -- no cleanup needed
|
next $ return True -- no cleanup needed
|
||||||
|
|
||||||
{- Try to find a copy of the file in one of the remotes,
|
{- Try to find a copy of the file in one of the remotes,
|
||||||
- and copy it to here. -}
|
- and copy it to here. -}
|
||||||
getKey :: Key -> AssociatedFile -> Annex Bool
|
getKey :: LiveUpdate -> Key -> AssociatedFile -> Annex Bool
|
||||||
getKey key afile = getKey' key afile
|
getKey lu key afile = getKey' lu key afile
|
||||||
=<< Remote.keyPossibilities (Remote.IncludeIgnored False) key
|
=<< Remote.keyPossibilities (Remote.IncludeIgnored False) key
|
||||||
|
|
||||||
getKey' :: Key -> AssociatedFile -> [Remote] -> Annex Bool
|
getKey' :: LiveUpdate -> Key -> AssociatedFile -> [Remote] -> Annex Bool
|
||||||
getKey' key afile = dispatch
|
getKey' lu key afile = dispatch
|
||||||
where
|
where
|
||||||
dispatch [] = do
|
dispatch [] = do
|
||||||
showNote (UnquotedString "not available")
|
showNote (UnquotedString "not available")
|
||||||
|
@ -119,5 +121,5 @@ getKey' key afile = dispatch
|
||||||
| otherwise = return True
|
| otherwise = return True
|
||||||
docopy r witness = do
|
docopy r witness = do
|
||||||
showAction $ UnquotedString $ "from " ++ Remote.name r
|
showAction $ UnquotedString $ "from " ++ Remote.name r
|
||||||
logStatusAfter key $
|
logStatusAfter lu key $
|
||||||
download r key afile stdRetry witness
|
download r key afile stdRetry witness
|
||||||
|
|
|
@ -66,10 +66,10 @@ start o si file k = startKey o afile (si, k, ai)
|
||||||
startKey :: MirrorOptions -> AssociatedFile -> (SeekInput, Key, ActionItem) -> CommandStart
|
startKey :: MirrorOptions -> AssociatedFile -> (SeekInput, Key, ActionItem) -> CommandStart
|
||||||
startKey o afile (si, key, ai) = case fromToOptions o of
|
startKey o afile (si, key, ai) = case fromToOptions o of
|
||||||
ToRemote r -> checkFailedTransferDirection ai Upload $ ifM (inAnnex key)
|
ToRemote r -> checkFailedTransferDirection ai Upload $ ifM (inAnnex key)
|
||||||
( Command.Move.toStart Command.Move.RemoveNever afile key ai si =<< getParsed r
|
( Command.Move.toStart NoLiveUpdate Command.Move.RemoveNever afile key ai si =<< getParsed r
|
||||||
, do
|
, do
|
||||||
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
||||||
Command.Drop.startRemote pcc afile ai si numcopies mincopies key (Command.Drop.DroppingUnused False)
|
Command.Drop.startRemote NoLiveUpdate pcc afile ai si numcopies mincopies key (Command.Drop.DroppingUnused False)
|
||||||
=<< getParsed r
|
=<< getParsed r
|
||||||
)
|
)
|
||||||
FromRemote r -> checkFailedTransferDirection ai Download $ do
|
FromRemote r -> checkFailedTransferDirection ai Download $ do
|
||||||
|
@ -78,12 +78,12 @@ startKey o afile (si, key, ai) = case fromToOptions o of
|
||||||
Left _ -> stop
|
Left _ -> stop
|
||||||
Right True -> ifM (inAnnex key)
|
Right True -> ifM (inAnnex key)
|
||||||
( stop
|
( stop
|
||||||
, Command.Get.start' (return True) Nothing key afile ai si
|
, Command.Get.start' NoLiveUpdate (return True) Nothing key afile ai si
|
||||||
)
|
)
|
||||||
Right False -> ifM (inAnnex key)
|
Right False -> ifM (inAnnex key)
|
||||||
( do
|
( do
|
||||||
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
||||||
Command.Drop.startLocal pcc afile ai si numcopies mincopies key [] (Command.Drop.DroppingUnused False)
|
Command.Drop.startLocal NoLiveUpdate pcc afile ai si numcopies mincopies key [] (Command.Drop.DroppingUnused False)
|
||||||
, stop
|
, stop
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
137
Command/Move.hs
137
Command/Move.hs
|
@ -75,7 +75,7 @@ seek' o fto = startConcurrency (stages fto) $ do
|
||||||
batchAnnexed fmt seeker keyaction
|
batchAnnexed fmt seeker keyaction
|
||||||
where
|
where
|
||||||
seeker = AnnexedFileSeeker
|
seeker = AnnexedFileSeeker
|
||||||
{ startAction = const $ start fto (removeWhen o)
|
{ startAction = const $ start NoLiveUpdate fto (removeWhen o)
|
||||||
, checkContentPresent = case fto of
|
, checkContentPresent = case fto of
|
||||||
FromOrToRemote (FromRemote _) -> Nothing
|
FromOrToRemote (FromRemote _) -> Nothing
|
||||||
FromOrToRemote (ToRemote _) -> Just True
|
FromOrToRemote (ToRemote _) -> Just True
|
||||||
|
@ -84,7 +84,7 @@ seek' o fto = startConcurrency (stages fto) $ do
|
||||||
FromAnywhereToRemote _ -> Nothing
|
FromAnywhereToRemote _ -> Nothing
|
||||||
, usesLocationLog = True
|
, usesLocationLog = True
|
||||||
}
|
}
|
||||||
keyaction = startKey fto (removeWhen o)
|
keyaction = startKey NoLiveUpdate fto (removeWhen o)
|
||||||
ww = WarnUnmatchLsFiles "move"
|
ww = WarnUnmatchLsFiles "move"
|
||||||
|
|
||||||
stages :: FromToHereOptions -> UsedStages
|
stages :: FromToHereOptions -> UsedStages
|
||||||
|
@ -94,49 +94,49 @@ stages ToHere = transferStages
|
||||||
stages (FromRemoteToRemote _ _) = transferStages
|
stages (FromRemoteToRemote _ _) = transferStages
|
||||||
stages (FromAnywhereToRemote _) = transferStages
|
stages (FromAnywhereToRemote _) = transferStages
|
||||||
|
|
||||||
start :: FromToHereOptions -> RemoveWhen -> SeekInput -> RawFilePath -> Key -> CommandStart
|
start :: LiveUpdate -> FromToHereOptions -> RemoveWhen -> SeekInput -> RawFilePath -> Key -> CommandStart
|
||||||
start fromto removewhen si f k = start' fromto removewhen afile si k ai
|
start lu fromto removewhen si f k = start' lu fromto removewhen afile si k ai
|
||||||
where
|
where
|
||||||
afile = AssociatedFile (Just f)
|
afile = AssociatedFile (Just f)
|
||||||
ai = mkActionItem (k, afile)
|
ai = mkActionItem (k, afile)
|
||||||
|
|
||||||
startKey :: FromToHereOptions -> RemoveWhen -> (SeekInput, Key, ActionItem) -> CommandStart
|
startKey :: LiveUpdate -> FromToHereOptions -> RemoveWhen -> (SeekInput, Key, ActionItem) -> CommandStart
|
||||||
startKey fromto removewhen (si, k, ai) =
|
startKey lu fromto removewhen (si, k, ai) =
|
||||||
start' fromto removewhen (AssociatedFile Nothing) si k ai
|
start' lu fromto removewhen (AssociatedFile Nothing) si k ai
|
||||||
|
|
||||||
start' :: FromToHereOptions -> RemoveWhen -> AssociatedFile -> SeekInput -> Key -> ActionItem -> CommandStart
|
start' :: LiveUpdate -> FromToHereOptions -> RemoveWhen -> AssociatedFile -> SeekInput -> Key -> ActionItem -> CommandStart
|
||||||
start' fromto removewhen afile si key ai =
|
start' lu fromto removewhen afile si key ai =
|
||||||
case fromto of
|
case fromto of
|
||||||
FromOrToRemote (FromRemote src) ->
|
FromOrToRemote (FromRemote src) ->
|
||||||
checkFailedTransferDirection ai Download $
|
checkFailedTransferDirection ai Download $
|
||||||
fromStart removewhen afile key ai si =<< getParsed src
|
fromStart lu removewhen afile key ai si =<< getParsed src
|
||||||
FromOrToRemote (ToRemote dest) ->
|
FromOrToRemote (ToRemote dest) ->
|
||||||
checkFailedTransferDirection ai Upload $
|
checkFailedTransferDirection ai Upload $
|
||||||
toStart removewhen afile key ai si =<< getParsed dest
|
toStart lu removewhen afile key ai si =<< getParsed dest
|
||||||
ToHere ->
|
ToHere ->
|
||||||
checkFailedTransferDirection ai Download $
|
checkFailedTransferDirection ai Download $
|
||||||
toHereStart removewhen afile key ai si
|
toHereStart lu removewhen afile key ai si
|
||||||
FromRemoteToRemote src dest -> do
|
FromRemoteToRemote src dest -> do
|
||||||
src' <- getParsed src
|
src' <- getParsed src
|
||||||
dest' <- getParsed dest
|
dest' <- getParsed dest
|
||||||
fromToStart removewhen afile key ai si src' dest'
|
fromToStart lu removewhen afile key ai si src' dest'
|
||||||
FromAnywhereToRemote dest -> do
|
FromAnywhereToRemote dest -> do
|
||||||
dest' <- getParsed dest
|
dest' <- getParsed dest
|
||||||
fromAnywhereToStart removewhen afile key ai si dest'
|
fromAnywhereToStart lu removewhen afile key ai si dest'
|
||||||
|
|
||||||
describeMoveAction :: RemoveWhen -> String
|
describeMoveAction :: RemoveWhen -> String
|
||||||
describeMoveAction RemoveNever = "copy"
|
describeMoveAction RemoveNever = "copy"
|
||||||
describeMoveAction _ = "move"
|
describeMoveAction _ = "move"
|
||||||
|
|
||||||
toStart :: RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> Remote -> CommandStart
|
toStart :: LiveUpdate -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> Remote -> CommandStart
|
||||||
toStart removewhen afile key ai si dest = do
|
toStart lu removewhen afile key ai si dest = do
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
if u == Remote.uuid dest
|
if u == Remote.uuid dest
|
||||||
then stop
|
then stop
|
||||||
else toStart' dest removewhen afile key ai si
|
else toStart' lu dest removewhen afile key ai si
|
||||||
|
|
||||||
toStart' :: Remote -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> CommandStart
|
toStart' :: LiveUpdate -> Remote -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> CommandStart
|
||||||
toStart' dest removewhen afile key ai si = do
|
toStart' lu dest removewhen afile key ai si = do
|
||||||
fast <- Annex.getRead Annex.fast
|
fast <- Annex.getRead Annex.fast
|
||||||
if fast && removewhen == RemoveNever
|
if fast && removewhen == RemoveNever
|
||||||
then ifM (expectedPresent dest key)
|
then ifM (expectedPresent dest key)
|
||||||
|
@ -147,18 +147,18 @@ toStart' dest removewhen afile key ai si = do
|
||||||
where
|
where
|
||||||
go fastcheck isthere =
|
go fastcheck isthere =
|
||||||
starting (describeMoveAction removewhen) (OnlyActionOn key ai) si $
|
starting (describeMoveAction removewhen) (OnlyActionOn key ai) si $
|
||||||
toPerform dest removewhen key afile fastcheck =<< isthere
|
toPerform lu dest removewhen key afile fastcheck =<< isthere
|
||||||
|
|
||||||
expectedPresent :: Remote -> Key -> Annex Bool
|
expectedPresent :: Remote -> Key -> Annex Bool
|
||||||
expectedPresent dest key = do
|
expectedPresent dest key = do
|
||||||
remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
|
remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
|
||||||
return $ dest `elem` remotes
|
return $ dest `elem` remotes
|
||||||
|
|
||||||
toPerform :: Remote -> RemoveWhen -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
|
toPerform :: LiveUpdate -> Remote -> RemoveWhen -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
|
||||||
toPerform = toPerform' Nothing
|
toPerform = toPerform' Nothing
|
||||||
|
|
||||||
toPerform' :: Maybe ContentRemovalLock -> Remote -> RemoveWhen -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
|
toPerform' :: Maybe ContentRemovalLock -> LiveUpdate -> Remote -> RemoveWhen -> Key -> AssociatedFile -> Bool -> Either String Bool -> CommandPerform
|
||||||
toPerform' mcontentlock dest removewhen key afile fastcheck isthere = do
|
toPerform' mcontentlock lu dest removewhen key afile fastcheck isthere = do
|
||||||
srcuuid <- getUUID
|
srcuuid <- getUUID
|
||||||
case isthere of
|
case isthere of
|
||||||
Left err -> do
|
Left err -> do
|
||||||
|
@ -170,7 +170,7 @@ toPerform' mcontentlock dest removewhen key afile fastcheck isthere = do
|
||||||
upload dest key afile stdRetry
|
upload dest key afile stdRetry
|
||||||
if ok
|
if ok
|
||||||
then finish deststartedwithcopy $
|
then finish deststartedwithcopy $
|
||||||
Remote.logStatus dest key InfoPresent
|
Remote.logStatus lu dest key InfoPresent
|
||||||
else do
|
else do
|
||||||
logMoveCleanup deststartedwithcopy
|
logMoveCleanup deststartedwithcopy
|
||||||
when fastcheck $
|
when fastcheck $
|
||||||
|
@ -179,7 +179,7 @@ toPerform' mcontentlock dest removewhen key afile fastcheck isthere = do
|
||||||
Right True -> logMove srcuuid destuuid True key $ \deststartedwithcopy ->
|
Right True -> logMove srcuuid destuuid True key $ \deststartedwithcopy ->
|
||||||
finish deststartedwithcopy $
|
finish deststartedwithcopy $
|
||||||
unlessM (expectedPresent dest key) $
|
unlessM (expectedPresent dest key) $
|
||||||
Remote.logStatus dest key InfoPresent
|
Remote.logStatus lu dest key InfoPresent
|
||||||
where
|
where
|
||||||
destuuid = Remote.uuid dest
|
destuuid = Remote.uuid dest
|
||||||
finish deststartedwithcopy setpresentremote = case removewhen of
|
finish deststartedwithcopy setpresentremote = case removewhen of
|
||||||
|
@ -189,7 +189,7 @@ toPerform' mcontentlock dest removewhen key afile fastcheck isthere = do
|
||||||
next $ return True
|
next $ return True
|
||||||
RemoveSafe -> lockcontentforremoval $ \contentlock -> do
|
RemoveSafe -> lockcontentforremoval $ \contentlock -> do
|
||||||
srcuuid <- getUUID
|
srcuuid <- getUUID
|
||||||
r <- willDropMakeItWorse srcuuid destuuid deststartedwithcopy key afile >>= \case
|
r <- willDropMakeItWorse lu srcuuid destuuid deststartedwithcopy key afile >>= \case
|
||||||
DropAllowed -> drophere setpresentremote contentlock "moved"
|
DropAllowed -> drophere setpresentremote contentlock "moved"
|
||||||
DropCheckNumCopies -> do
|
DropCheckNumCopies -> do
|
||||||
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
||||||
|
@ -214,7 +214,7 @@ toPerform' mcontentlock dest removewhen key afile fastcheck isthere = do
|
||||||
removeAnnex contentlock
|
removeAnnex contentlock
|
||||||
next $ do
|
next $ do
|
||||||
() <- setpresentremote
|
() <- setpresentremote
|
||||||
Command.Drop.cleanupLocal key (Command.Drop.DroppingUnused False)
|
Command.Drop.cleanupLocal lu key (Command.Drop.DroppingUnused False)
|
||||||
faileddrophere setpresentremote = do
|
faileddrophere setpresentremote = do
|
||||||
showLongNote "(Use --force to override this check, or adjust numcopies.)"
|
showLongNote "(Use --force to override this check, or adjust numcopies.)"
|
||||||
showLongNote "Content not dropped from here."
|
showLongNote "Content not dropped from here."
|
||||||
|
@ -231,13 +231,14 @@ toPerform' mcontentlock dest removewhen key afile fastcheck isthere = do
|
||||||
-- is present, but due to buffering, may find it present for the
|
-- is present, but due to buffering, may find it present for the
|
||||||
-- second file before the first is dropped. If so, nothing remains
|
-- second file before the first is dropped. If so, nothing remains
|
||||||
-- to be done except for cleaning up.
|
-- to be done except for cleaning up.
|
||||||
lockfailed = next $ Command.Drop.cleanupLocal key (Command.Drop.DroppingUnused False)
|
lockfailed = next $ Command.Drop.cleanupLocal lu key
|
||||||
|
(Command.Drop.DroppingUnused False)
|
||||||
|
|
||||||
fromStart :: RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> Remote -> CommandStart
|
fromStart :: LiveUpdate -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> Remote -> CommandStart
|
||||||
fromStart removewhen afile key ai si src =
|
fromStart lu removewhen afile key ai si src =
|
||||||
stopUnless (fromOk src key) $
|
stopUnless (fromOk src key) $
|
||||||
starting (describeMoveAction removewhen) (OnlyActionOn key ai) si $
|
starting (describeMoveAction removewhen) (OnlyActionOn key ai) si $
|
||||||
fromPerform src removewhen key afile
|
fromPerform lu src removewhen key afile
|
||||||
|
|
||||||
fromOk :: Remote -> Key -> Annex Bool
|
fromOk :: Remote -> Key -> Annex Bool
|
||||||
fromOk src key
|
fromOk src key
|
||||||
|
@ -257,14 +258,14 @@ fromOk src key
|
||||||
remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
|
remotes <- Remote.keyPossibilities (Remote.IncludeIgnored True) key
|
||||||
return $ u /= Remote.uuid src && elem src remotes
|
return $ u /= Remote.uuid src && elem src remotes
|
||||||
|
|
||||||
fromPerform :: Remote -> RemoveWhen -> Key -> AssociatedFile -> CommandPerform
|
fromPerform :: LiveUpdate -> Remote -> RemoveWhen -> Key -> AssociatedFile -> CommandPerform
|
||||||
fromPerform src removewhen key afile = do
|
fromPerform lu src removewhen key afile = do
|
||||||
present <- inAnnex key
|
present <- inAnnex key
|
||||||
finish <- fromPerform' present True src key afile
|
finish <- fromPerform' lu present True src key afile
|
||||||
finish removewhen
|
finish removewhen
|
||||||
|
|
||||||
fromPerform' :: Bool -> Bool -> Remote -> Key -> AssociatedFile -> Annex (RemoveWhen -> CommandPerform)
|
fromPerform' :: LiveUpdate -> Bool -> Bool -> Remote -> Key -> AssociatedFile -> Annex (RemoveWhen -> CommandPerform)
|
||||||
fromPerform' present updatelocationlog src key afile = do
|
fromPerform' lu present updatelocationlog src key afile = do
|
||||||
showAction $ UnquotedString $ "from " ++ Remote.name src
|
showAction $ UnquotedString $ "from " ++ Remote.name src
|
||||||
destuuid <- getUUID
|
destuuid <- getUUID
|
||||||
logMove (Remote.uuid src) destuuid present key $ \deststartedwithcopy ->
|
logMove (Remote.uuid src) destuuid present key $ \deststartedwithcopy ->
|
||||||
|
@ -279,7 +280,7 @@ fromPerform' present updatelocationlog src key afile = do
|
||||||
download src key afile stdRetry
|
download src key afile stdRetry
|
||||||
|
|
||||||
logdownload a
|
logdownload a
|
||||||
| updatelocationlog = logStatusAfter key a
|
| updatelocationlog = logStatusAfter lu key a
|
||||||
| otherwise = a
|
| otherwise = a
|
||||||
|
|
||||||
finish deststartedwithcopy False _ = do
|
finish deststartedwithcopy False _ = do
|
||||||
|
@ -291,17 +292,20 @@ fromPerform' present updatelocationlog src key afile = do
|
||||||
finish deststartedwithcopy True RemoveSafe = do
|
finish deststartedwithcopy True RemoveSafe = do
|
||||||
destuuid <- getUUID
|
destuuid <- getUUID
|
||||||
lockContentShared key Nothing $ \_lck ->
|
lockContentShared key Nothing $ \_lck ->
|
||||||
fromDrop src destuuid deststartedwithcopy key afile id
|
fromDrop lu src destuuid deststartedwithcopy key afile id
|
||||||
|
|
||||||
fromDrop :: Remote -> UUID -> DestStartedWithCopy -> Key -> AssociatedFile -> ([UnVerifiedCopy] -> [UnVerifiedCopy])-> CommandPerform
|
fromDrop :: LiveUpdate -> Remote -> UUID -> DestStartedWithCopy -> Key -> AssociatedFile -> ([UnVerifiedCopy] -> [UnVerifiedCopy])-> CommandPerform
|
||||||
fromDrop src destuuid deststartedwithcopy key afile adjusttocheck =
|
fromDrop lu src destuuid deststartedwithcopy key afile adjusttocheck =
|
||||||
willDropMakeItWorse (Remote.uuid src) destuuid deststartedwithcopy key afile >>= \case
|
willDropMakeItWorse lu (Remote.uuid src) destuuid deststartedwithcopy key afile >>= \case
|
||||||
DropAllowed -> dropremote Nothing "moved"
|
DropAllowed -> dropremote Nothing "moved"
|
||||||
DropCheckNumCopies -> do
|
DropCheckNumCopies -> do
|
||||||
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
(numcopies, mincopies) <- getSafestNumMinCopies afile key
|
||||||
(tocheck, verified) <- verifiableCopies key [Remote.uuid src]
|
(tocheck, verified) <- verifiableCopies key [Remote.uuid src]
|
||||||
verifyEnoughCopiesToDrop "" key (Just (Remote.uuid src)) Nothing numcopies mincopies [Remote.uuid src] verified
|
verifyEnoughCopiesToDrop "" key
|
||||||
(adjusttocheck tocheck) dropremotewithproof faileddropremote
|
(Just (Remote.uuid src)) Nothing
|
||||||
|
numcopies mincopies [Remote.uuid src]
|
||||||
|
verified (adjusttocheck tocheck)
|
||||||
|
dropremotewithproof faileddropremote
|
||||||
DropWorse -> faileddropremote
|
DropWorse -> faileddropremote
|
||||||
where
|
where
|
||||||
showproof proof = "proof: " ++ show proof
|
showproof proof = "proof: " ++ show proof
|
||||||
|
@ -318,7 +322,8 @@ fromDrop src destuuid deststartedwithcopy key afile adjusttocheck =
|
||||||
ok <- Remote.action (Remote.removeKey src mproof key)
|
ok <- Remote.action (Remote.removeKey src mproof key)
|
||||||
when ok $
|
when ok $
|
||||||
logMoveCleanup deststartedwithcopy
|
logMoveCleanup deststartedwithcopy
|
||||||
next $ Command.Drop.cleanupRemote key src (Command.Drop.DroppingUnused False) ok
|
next $ Command.Drop.cleanupRemote lu key src
|
||||||
|
(Command.Drop.DroppingUnused False) ok
|
||||||
|
|
||||||
faileddropremote = do
|
faileddropremote = do
|
||||||
showLongNote "(Use --force to override this check, or adjust numcopies.)"
|
showLongNote "(Use --force to override this check, or adjust numcopies.)"
|
||||||
|
@ -331,27 +336,27 @@ fromDrop src destuuid deststartedwithcopy key afile adjusttocheck =
|
||||||
-
|
-
|
||||||
- When moving, the content is removed from all the reachable remotes that
|
- When moving, the content is removed from all the reachable remotes that
|
||||||
- it can safely be removed from. -}
|
- it can safely be removed from. -}
|
||||||
toHereStart :: RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> CommandStart
|
toHereStart :: LiveUpdate -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> CommandStart
|
||||||
toHereStart removewhen afile key ai si =
|
toHereStart lu removewhen afile key ai si =
|
||||||
startingNoMessage (OnlyActionOn key ai) $ do
|
startingNoMessage (OnlyActionOn key ai) $ do
|
||||||
rs <- Remote.keyPossibilities (Remote.IncludeIgnored False) key
|
rs <- Remote.keyPossibilities (Remote.IncludeIgnored False) key
|
||||||
forM_ rs $ \r ->
|
forM_ rs $ \r ->
|
||||||
includeCommandAction $
|
includeCommandAction $
|
||||||
starting (describeMoveAction removewhen) ai si $
|
starting (describeMoveAction removewhen) ai si $
|
||||||
fromPerform r removewhen key afile
|
fromPerform lu r removewhen key afile
|
||||||
next $ return True
|
next $ return True
|
||||||
|
|
||||||
fromToStart :: RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> Remote -> Remote -> CommandStart
|
fromToStart :: LiveUpdate -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> Remote -> Remote -> CommandStart
|
||||||
fromToStart removewhen afile key ai si src dest =
|
fromToStart lu removewhen afile key ai si src dest =
|
||||||
stopUnless somethingtodo $ do
|
stopUnless somethingtodo $ do
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
if u == Remote.uuid src
|
if u == Remote.uuid src
|
||||||
then toStart removewhen afile key ai si dest
|
then toStart lu removewhen afile key ai si dest
|
||||||
else if u == Remote.uuid dest
|
else if u == Remote.uuid dest
|
||||||
then fromStart removewhen afile key ai si src
|
then fromStart lu removewhen afile key ai si src
|
||||||
else stopUnless (fromOk src key) $
|
else stopUnless (fromOk src key) $
|
||||||
starting (describeMoveAction removewhen) (OnlyActionOn key ai) si $
|
starting (describeMoveAction removewhen) (OnlyActionOn key ai) si $
|
||||||
fromToPerform src dest removewhen key afile
|
fromToPerform lu src dest removewhen key afile
|
||||||
where
|
where
|
||||||
somethingtodo
|
somethingtodo
|
||||||
| Remote.uuid src == Remote.uuid dest = return False
|
| Remote.uuid src == Remote.uuid dest = return False
|
||||||
|
@ -361,22 +366,22 @@ fromToStart removewhen afile key ai si src dest =
|
||||||
then not <$> expectedPresent dest key
|
then not <$> expectedPresent dest key
|
||||||
else return True
|
else return True
|
||||||
|
|
||||||
fromAnywhereToStart :: RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> Remote -> CommandStart
|
fromAnywhereToStart :: LiveUpdate -> RemoveWhen -> AssociatedFile -> Key -> ActionItem -> SeekInput -> Remote -> CommandStart
|
||||||
fromAnywhereToStart removewhen afile key ai si dest =
|
fromAnywhereToStart lu removewhen afile key ai si dest =
|
||||||
stopUnless somethingtodo $ do
|
stopUnless somethingtodo $ do
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
if u == Remote.uuid dest
|
if u == Remote.uuid dest
|
||||||
then toHereStart removewhen afile key ai si
|
then toHereStart lu removewhen afile key ai si
|
||||||
else startingNoMessage (OnlyActionOn key ai) $ do
|
else startingNoMessage (OnlyActionOn key ai) $ do
|
||||||
rs <- filter (/= dest)
|
rs <- filter (/= dest)
|
||||||
<$> Remote.keyPossibilities (Remote.IncludeIgnored False) key
|
<$> Remote.keyPossibilities (Remote.IncludeIgnored False) key
|
||||||
forM_ rs $ \r ->
|
forM_ rs $ \r ->
|
||||||
includeCommandAction $
|
includeCommandAction $
|
||||||
starting (describeMoveAction removewhen) ai si $
|
starting (describeMoveAction removewhen) ai si $
|
||||||
fromToPerform r dest removewhen key afile
|
fromToPerform lu r dest removewhen key afile
|
||||||
whenM (inAnnex key) $
|
whenM (inAnnex key) $
|
||||||
void $ includeCommandAction $
|
void $ includeCommandAction $
|
||||||
toStart removewhen afile key ai si dest
|
toStart lu removewhen afile key ai si dest
|
||||||
next $ return True
|
next $ return True
|
||||||
where
|
where
|
||||||
somethingtodo = do
|
somethingtodo = do
|
||||||
|
@ -400,8 +405,8 @@ fromAnywhereToStart removewhen afile key ai si dest =
|
||||||
- may end up locally present, or not. This is similar to the behavior
|
- may end up locally present, or not. This is similar to the behavior
|
||||||
- when running `git-annex move --to` concurrently with git-annex get.
|
- when running `git-annex move --to` concurrently with git-annex get.
|
||||||
-}
|
-}
|
||||||
fromToPerform :: Remote -> Remote -> RemoveWhen -> Key -> AssociatedFile -> CommandPerform
|
fromToPerform :: LiveUpdate -> Remote -> Remote -> RemoveWhen -> Key -> AssociatedFile -> CommandPerform
|
||||||
fromToPerform src dest removewhen key afile = do
|
fromToPerform lu src dest removewhen key afile = do
|
||||||
hereuuid <- getUUID
|
hereuuid <- getUUID
|
||||||
loggedpresent <- any (== hereuuid)
|
loggedpresent <- any (== hereuuid)
|
||||||
<$> loggedLocations key
|
<$> loggedLocations key
|
||||||
|
@ -441,7 +446,7 @@ fromToPerform src dest removewhen key afile = do
|
||||||
"to " ++ Remote.name dest
|
"to " ++ Remote.name dest
|
||||||
-- The log may not indicate dest's copy
|
-- The log may not indicate dest's copy
|
||||||
-- yet, so make sure it does.
|
-- yet, so make sure it does.
|
||||||
logChange key (Remote.uuid dest) InfoPresent
|
logChange lu key (Remote.uuid dest) InfoPresent
|
||||||
-- Drop from src, checking copies including
|
-- Drop from src, checking copies including
|
||||||
-- the one already in dest.
|
-- the one already in dest.
|
||||||
dropfromsrc id
|
dropfromsrc id
|
||||||
|
@ -472,13 +477,13 @@ fromToPerform src dest removewhen key afile = do
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fromsrc present = fromPerform' present False src key afile
|
fromsrc present = fromPerform' lu present False src key afile
|
||||||
|
|
||||||
todest mcontentlock removewhen' = toPerform' mcontentlock dest removewhen' key afile False
|
todest mcontentlock removewhen' = toPerform' mcontentlock lu dest removewhen' key afile False
|
||||||
|
|
||||||
dropfromsrc adjusttocheck = case removewhen of
|
dropfromsrc adjusttocheck = case removewhen of
|
||||||
RemoveSafe -> logMove (Remote.uuid src) (Remote.uuid dest) True key $ \deststartedwithcopy ->
|
RemoveSafe -> logMove (Remote.uuid src) (Remote.uuid dest) True key $ \deststartedwithcopy ->
|
||||||
fromDrop src (Remote.uuid dest) deststartedwithcopy key afile adjusttocheck
|
fromDrop lu src (Remote.uuid dest) deststartedwithcopy key afile adjusttocheck
|
||||||
RemoveNever -> next (return True)
|
RemoveNever -> next (return True)
|
||||||
|
|
||||||
combinecleanups a b = a >>= \case
|
combinecleanups a b = a >>= \case
|
||||||
|
@ -521,9 +526,9 @@ fromToPerform src dest removewhen key afile = do
|
||||||
- This function checks all that. It needs to know if the destination
|
- This function checks all that. It needs to know if the destination
|
||||||
- repository already had a copy of the file before the move began.
|
- repository already had a copy of the file before the move began.
|
||||||
-}
|
-}
|
||||||
willDropMakeItWorse :: UUID -> UUID -> DestStartedWithCopy -> Key -> AssociatedFile -> Annex DropCheck
|
willDropMakeItWorse :: LiveUpdate -> UUID -> UUID -> DestStartedWithCopy -> Key -> AssociatedFile -> Annex DropCheck
|
||||||
willDropMakeItWorse srcuuid destuuid (DestStartedWithCopy deststartedwithcopy _) key afile =
|
willDropMakeItWorse lu srcuuid destuuid (DestStartedWithCopy deststartedwithcopy _) key afile =
|
||||||
ifM (Command.Drop.checkRequiredContent (Command.Drop.PreferredContentChecked False) srcuuid key afile)
|
ifM (Command.Drop.checkRequiredContent lu (Command.Drop.PreferredContentChecked False) srcuuid key afile)
|
||||||
( if deststartedwithcopy || isClusterUUID srcuuid
|
( if deststartedwithcopy || isClusterUUID srcuuid
|
||||||
then unlessforced DropCheckNumCopies
|
then unlessforced DropCheckNumCopies
|
||||||
else ifM checktrustlevel
|
else ifM checktrustlevel
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue