From 152be2948b6fb5ae227de928d6761318fcf9d4a9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Jan 2023 14:03:26 -0400 Subject: [PATCH] use transfer stages for copy --from See commit e04a9314392037e7b54a098f9709fc6040327411 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 --- Command/Copy.hs | 8 +------- Command/Move.hs | 13 +++++++------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Command/Copy.hs b/Command/Copy.hs index e53e5cdbe4..5c9e97dcef 100644 --- a/Command/Copy.hs +++ b/Command/Copy.hs @@ -50,7 +50,7 @@ seek o = case fromToOptions o of Nothing -> giveup "Specify --from or --to" seek' :: CopyOptions -> FromToHereOptions -> CommandSeek -seek' o fto = startConcurrend stages $ do +seek' o fto = startConcurrency (Command.Move.stages fto) $ do case batchOption o of NoBatch -> withKeyOptions (keyOptions o) (autoMode o) seeker @@ -73,12 +73,6 @@ seek' o fto = startConcurrend stages $ do } 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. - However, auto mode avoids unnecessary copies, and avoids getting or - sending non-preferred content. -} diff --git a/Command/Move.hs b/Command/Move.hs index 23a319645d..528e6ce22c 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -65,7 +65,7 @@ seek o = case fromToOptions o of Nothing -> giveup "Specify --from or --to" seek' :: MoveOptions -> FromToHereOptions -> CommandSeek -seek' o fto = startConcurrency stages $ do +seek' o fto = startConcurrency (stages fto) $ do case batchOption o of NoBatch -> withKeyOptions (keyOptions o) False seeker (commandAction . keyaction) @@ -83,14 +83,15 @@ seek' o fto = startConcurrency stages $ do FromRemoteToRemote _ _ -> Nothing , usesLocationLog = True } - stages = case fto of - FromOrToRemote (FromRemote _) -> transferStages - FromOrToRemote (ToRemote _) -> commandStages - ToHere -> transferStages - FromRemoteToRemote _ _ -> transferStages keyaction = startKey fto (removeWhen o) 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 fromto removewhen si f k = start' fromto removewhen afile si k ai where