From ac480822a9ab7b92ea8eddc445e8579c17b31115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= <69477666+tleedjarv@users.noreply.github.com> Date: Mon, 2 Aug 2021 14:16:32 +0200 Subject: [PATCH] Resume partial transfers for local syncs There already is logic with remote syncs to check if a previous partial transfer exists and resume it as far as possible, instead of restarting. This patch enables the same logic for local syncs. --- src/copy.ml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/copy.ml b/src/copy.ml index 60a051155..0f385c4cc 100644 --- a/src/copy.ml +++ b/src/copy.ml @@ -317,6 +317,26 @@ let localFile fspathFrom pathFrom fspathTo pathTo `RESS ressLength ido; setFileinfo fspathTo pathTo realPathTo update desc) +let localFileWithResume + fspathFrom pathFrom fspathTo pathTo realPathTo update desc fp ress ido = + let (_, isTransferred) = fileIsTransferred fspathTo pathTo desc fp ress in + if isTransferred then begin + (* File is already fully transferred (from some interrupted + previous transfer). So just make sure permissions are right. *) + Trace.log + (Printf.sprintf "%s/%s has already been transferred\n" + (Fspath.toDebugString fspathTo) (Path.toString realPathTo)); + setFileinfo fspathTo pathTo realPathTo update desc; + match ido with + | None -> () + | Some id -> + let len = Uutil.Filesize.add (Props.length desc) (Osx.ressLength ress) in + Uutil.showProgress id len "alr" + end else + localFile + fspathFrom pathFrom fspathTo pathTo realPathTo + update desc (Osx.ressLength ress) ido + (****) let tryCopyMovedFile fspathTo pathTo realPathTo update desc fp ress id = @@ -959,9 +979,9 @@ let file rootFrom pathFrom rootTo fspathTo pathTo realPathTo let timer = Trace.startTimer "Transmitting file" in begin match rootFrom, rootTo with (Common.Local, fspathFrom), (Common.Local, realFspathTo) -> - localFile + localFileWithResume fspathFrom pathFrom fspathTo pathTo realPathTo - update desc (Osx.ressLength ress) (Some id); + update desc fp ress (Some id); paranoidCheck fspathTo pathTo realPathTo desc fp ress | _ -> transferFile