use transfer stages for copy --from

See commit e04a931439 for an explanation
of why move uses transfer stages for --from, but command stages for
--to. At the point of that commit, copy was actually already using
command stages for everything, so the commit was incorrect about
improving copy --to.

But, the same reasoning about --from applies to copy as to move; when
verification is not done incrementally, download and verification are
the main two stages. The cleanup stage for copy is even less work than
for move (it doesn't drop from the remote).

Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
Joey Hess 2023-01-24 14:03:26 -04:00
parent 579d9b60c1
commit 152be2948b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 8 additions and 13 deletions

View file

@ -50,7 +50,7 @@ seek o = case fromToOptions o of
Nothing -> giveup "Specify --from or --to" Nothing -> giveup "Specify --from or --to"
seek' :: CopyOptions -> FromToHereOptions -> CommandSeek seek' :: CopyOptions -> FromToHereOptions -> CommandSeek
seek' o fto = startConcurrend stages $ do seek' o fto = startConcurrency (Command.Move.stages fto) $ do
case batchOption o of case batchOption o of
NoBatch -> withKeyOptions NoBatch -> withKeyOptions
(keyOptions o) (autoMode o) seeker (keyOptions o) (autoMode o) seeker
@ -73,12 +73,6 @@ seek' o fto = startConcurrend stages $ do
} }
keyaction = Command.Move.startKey fto Command.Move.RemoveNever keyaction = Command.Move.startKey fto Command.Move.RemoveNever
stages = case fto of
FromOrToRemote (FromRemote _) -> commandStages
FromOrToRemote (ToRemote _) -> commandStages
ToHere -> commandStages
FromRemoteToRemote _ _ -> transferStages
{- 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. -}

View file

@ -65,7 +65,7 @@ seek o = case fromToOptions o of
Nothing -> giveup "Specify --from or --to" Nothing -> giveup "Specify --from or --to"
seek' :: MoveOptions -> FromToHereOptions -> CommandSeek seek' :: MoveOptions -> FromToHereOptions -> CommandSeek
seek' o fto = startConcurrency stages $ do seek' o fto = startConcurrency (stages fto) $ do
case batchOption o of case batchOption o of
NoBatch -> withKeyOptions (keyOptions o) False seeker NoBatch -> withKeyOptions (keyOptions o) False seeker
(commandAction . keyaction) (commandAction . keyaction)
@ -83,14 +83,15 @@ seek' o fto = startConcurrency stages $ do
FromRemoteToRemote _ _ -> Nothing FromRemoteToRemote _ _ -> Nothing
, usesLocationLog = True , usesLocationLog = True
} }
stages = case fto of
FromOrToRemote (FromRemote _) -> transferStages
FromOrToRemote (ToRemote _) -> commandStages
ToHere -> transferStages
FromRemoteToRemote _ _ -> transferStages
keyaction = startKey fto (removeWhen o) keyaction = startKey fto (removeWhen o)
ww = WarnUnmatchLsFiles ww = WarnUnmatchLsFiles
stages :: FromToHereOptions -> UsedStages
stages (FromOrToRemote (FromRemote _)) = transferStages
stages (FromOrToRemote (ToRemote _)) = commandStages
stages ToHere = transferStages
stages (FromRemoteToRemote _ _) = transferStages
start :: FromToHereOptions -> RemoveWhen -> SeekInput -> RawFilePath -> Key -> CommandStart start :: FromToHereOptions -> RemoveWhen -> SeekInput -> RawFilePath -> Key -> CommandStart
start fromto removewhen si f k = start' fromto removewhen afile si k ai start fromto removewhen si f k = start' fromto removewhen afile si k ai
where where