Add progress logging for large uploads

* Add progress logging for large uploads in non verbose mode
This commit is contained in:
abraunegg 2018-08-04 20:15:18 +10:00
parent 6daa637ff2
commit 27b89a4922
2 changed files with 4 additions and 2 deletions

View file

@ -631,11 +631,11 @@ final class SyncEngine
private void downloadFileItem(Item item, string path) private void downloadFileItem(Item item, string path)
{ {
assert(item.type == ItemType.file); assert(item.type == ItemType.file);
write("Downloading ", path, "..."); write("Downloading ", path, " ...");
onedrive.downloadById(item.driveId, item.id, path); onedrive.downloadById(item.driveId, item.id, path);
setTimes(path, item.mtime, item.mtime); setTimes(path, item.mtime, item.mtime);
writeln(" done."); writeln(" done.");
log.fileOnly("Downloading ", path, "... done."); log.fileOnly("Downloading ", path, " ... done.");
} }
// returns true if the given item corresponds to the local one // returns true if the given item corresponds to the local one

View file

@ -91,6 +91,7 @@ struct UploadSession
JSONValue response; JSONValue response;
while (true) { while (true) {
long fragSize = fragmentSize < fileSize - offset ? fragmentSize : fileSize - offset; long fragSize = fragmentSize < fileSize - offset ? fragmentSize : fileSize - offset;
log.log("Upload Progress: ", double(offset)/fileSize*100,"%");
log.vlog("Uploading fragment: ", offset, "-", offset + fragSize, "/", fileSize); log.vlog("Uploading fragment: ", offset, "-", offset + fragSize, "/", fileSize);
response = onedrive.uploadFragment( response = onedrive.uploadFragment(
session["uploadUrl"].str, session["uploadUrl"].str,
@ -107,6 +108,7 @@ struct UploadSession
save(); save();
} }
// upload complete // upload complete
log.log("Upload Progress: ", double(offset)/fileSize*100,"%");
remove(sessionFilePath); remove(sessionFilePath);
return response; return response;
} }