Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume partial transfers for local syncs #571

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/copy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down