mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-16 12:45:14 +02:00
Fix up large file handling output
* Fix up large file handling output * Fix calculation error for upload fragments
This commit is contained in:
parent
abe4439014
commit
8a7a85062c
|
@ -1335,7 +1335,7 @@ class OneDriveApi {
|
||||||
// For each onProgress, what is the % of dlnow to dltotal
|
// For each onProgress, what is the % of dlnow to dltotal
|
||||||
// floor - rounds down to nearest whole number
|
// floor - rounds down to nearest whole number
|
||||||
real currentDLPercent = floor(double(dlnow)/dltotal*100);
|
real currentDLPercent = floor(double(dlnow)/dltotal*100);
|
||||||
string downloadLogEntry = leftJustify("Downloading: " ~ filename ~ " ", 77, '.');
|
string downloadLogEntry = "Downloading: " ~ filename ~ " ... ";
|
||||||
|
|
||||||
// Have we started downloading?
|
// Have we started downloading?
|
||||||
if (currentDLPercent > 0){
|
if (currentDLPercent > 0){
|
||||||
|
@ -1380,8 +1380,8 @@ class OneDriveApi {
|
||||||
segmentCount++;
|
segmentCount++;
|
||||||
auto eta = calc_eta(segmentCount, expected_total_segments, start_unix_time);
|
auto eta = calc_eta(segmentCount, expected_total_segments, start_unix_time);
|
||||||
dur!"seconds"(eta).split!("hours", "minutes", "seconds")(h, m, s);
|
dur!"seconds"(eta).split!("hours", "minutes", "seconds")(h, m, s);
|
||||||
etaString = format!"| ETA %02d:%02d:%02d"( h, m, s);
|
etaString = format!"| ETA %02d:%02d:%02d"( h, m, s);
|
||||||
string percentage = " " ~ leftJustify(to!string(currentDLPercent) ~ "%", 6, ' ');
|
string percentage = leftJustify(to!string(currentDLPercent) ~ "%", 5, ' ');
|
||||||
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
||||||
} else {
|
} else {
|
||||||
// 100% done
|
// 100% done
|
||||||
|
@ -1389,7 +1389,7 @@ class OneDriveApi {
|
||||||
auto upload_duration = cast(int)(end_unix_time - start_unix_time);
|
auto upload_duration = cast(int)(end_unix_time - start_unix_time);
|
||||||
dur!"seconds"(upload_duration).split!("hours", "minutes", "seconds")(h, m, s);
|
dur!"seconds"(upload_duration).split!("hours", "minutes", "seconds")(h, m, s);
|
||||||
etaString = format!"| DONE in %02d:%02d:%02d"( h, m, s);
|
etaString = format!"| DONE in %02d:%02d:%02d"( h, m, s);
|
||||||
string percentage = " " ~ leftJustify(to!string(currentDLPercent) ~ "%", 6, ' ');
|
string percentage = leftJustify(to!string(currentDLPercent) ~ "%", 5, ' ');
|
||||||
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1412,8 +1412,8 @@ class OneDriveApi {
|
||||||
segmentCount++;
|
segmentCount++;
|
||||||
auto eta = calc_eta(segmentCount, expected_total_segments, start_unix_time);
|
auto eta = calc_eta(segmentCount, expected_total_segments, start_unix_time);
|
||||||
dur!"seconds"(eta).split!("hours", "minutes", "seconds")(h, m, s);
|
dur!"seconds"(eta).split!("hours", "minutes", "seconds")(h, m, s);
|
||||||
etaString = format!"| ETA %02d:%02d:%02d"( h, m, s);
|
etaString = format!"| ETA %02d:%02d:%02d"( h, m, s);
|
||||||
string percentage = " " ~ leftJustify(to!string(currentDLPercent) ~ "%", 6, ' ');
|
string percentage = leftJustify(to!string(currentDLPercent) ~ "%", 5, ' ');
|
||||||
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
||||||
} else {
|
} else {
|
||||||
// 100% done
|
// 100% done
|
||||||
|
@ -1421,7 +1421,7 @@ class OneDriveApi {
|
||||||
auto upload_duration = cast(int)(end_unix_time - start_unix_time);
|
auto upload_duration = cast(int)(end_unix_time - start_unix_time);
|
||||||
dur!"seconds"(upload_duration).split!("hours", "minutes", "seconds")(h, m, s);
|
dur!"seconds"(upload_duration).split!("hours", "minutes", "seconds")(h, m, s);
|
||||||
etaString = format!"| DONE in %02d:%02d:%02d"( h, m, s);
|
etaString = format!"| DONE in %02d:%02d:%02d"( h, m, s);
|
||||||
string percentage = " " ~ leftJustify(to!string(currentDLPercent) ~ "%", 6, ' ');
|
string percentage = leftJustify(to!string(currentDLPercent) ~ "%", 5, ' ');
|
||||||
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1433,8 +1433,8 @@ class OneDriveApi {
|
||||||
if ((currentDLPercent == 0) && (!barInit)) {
|
if ((currentDLPercent == 0) && (!barInit)) {
|
||||||
// Calculate the output
|
// Calculate the output
|
||||||
segmentCount++;
|
segmentCount++;
|
||||||
etaString = "| ETA --:--:--";
|
etaString = "| ETA --:--:--";
|
||||||
string percentage = " " ~ leftJustify(to!string(currentDLPercent) ~ "%", 6, ' ');
|
string percentage = leftJustify(to!string(currentDLPercent) ~ "%", 5, ' ');
|
||||||
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
addLogEntry(downloadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
||||||
barInit = true;
|
barInit = true;
|
||||||
}
|
}
|
||||||
|
|
15
src/sync.d
15
src/sync.d
|
@ -24,6 +24,7 @@ import std.string;
|
||||||
import std.uni;
|
import std.uni;
|
||||||
import std.uri;
|
import std.uri;
|
||||||
import std.utf;
|
import std.utf;
|
||||||
|
import std.math;
|
||||||
|
|
||||||
// What other modules that we have created do we need to import?
|
// What other modules that we have created do we need to import?
|
||||||
import config;
|
import config;
|
||||||
|
@ -5136,11 +5137,11 @@ class SyncEngine {
|
||||||
ulong fragmentCount = 0;
|
ulong fragmentCount = 0;
|
||||||
ulong fragSize = 0;
|
ulong fragSize = 0;
|
||||||
ulong offset = uploadSessionData["nextExpectedRanges"][0].str.splitter('-').front.to!ulong;
|
ulong offset = uploadSessionData["nextExpectedRanges"][0].str.splitter('-').front.to!ulong;
|
||||||
size_t expected_total_fragments = (roundTo!int(double(thisFileSize)/double(fragmentSize)));
|
size_t expected_total_fragments = cast(ulong) ceil(double(thisFileSize) / double(fragmentSize));
|
||||||
ulong start_unix_time = Clock.currTime.toUnixTime();
|
ulong start_unix_time = Clock.currTime.toUnixTime();
|
||||||
int h, m, s;
|
int h, m, s;
|
||||||
string etaString;
|
string etaString;
|
||||||
string uploadLogEntry = leftJustify("Uploading: " ~ uploadSessionData["localPath"].str ~ " ", 76, '.');
|
string uploadLogEntry = "Uploading: " ~ uploadSessionData["localPath"].str ~ " ... ";
|
||||||
|
|
||||||
// Start the session upload using the active API instance for this thread
|
// Start the session upload using the active API instance for this thread
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -5151,17 +5152,17 @@ class SyncEngine {
|
||||||
auto eta = calc_eta((fragmentCount -1), expected_total_fragments, start_unix_time);
|
auto eta = calc_eta((fragmentCount -1), expected_total_fragments, start_unix_time);
|
||||||
if (eta == 0) {
|
if (eta == 0) {
|
||||||
// Initial calculation ...
|
// Initial calculation ...
|
||||||
etaString = format!"| ETA --:--:--";
|
etaString = format!"| ETA --:--:--";
|
||||||
} else {
|
} else {
|
||||||
// we have at least an ETA provided
|
// we have at least an ETA provided
|
||||||
dur!"seconds"(eta).split!("hours", "minutes", "seconds")(h, m, s);
|
dur!"seconds"(eta).split!("hours", "minutes", "seconds")(h, m, s);
|
||||||
etaString = format!"| ETA %02d:%02d:%02d"( h, m, s);
|
etaString = format!"| ETA %02d:%02d:%02d"( h, m, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate this progress output
|
// Calculate this progress output
|
||||||
auto ratio = cast(double)(fragmentCount -1) / expected_total_fragments;
|
auto ratio = cast(double)(fragmentCount -1) / expected_total_fragments;
|
||||||
// Convert the ratio to a percentage and format it to two decimal places
|
// Convert the ratio to a percentage and format it to two decimal places
|
||||||
string percentage = leftJustify(format(" %05.2f%%", ratio * 100), 8, ' ');
|
string percentage = leftJustify(format("%d%%", cast(int)(ratio * 100)), 5, ' ');
|
||||||
addLogEntry(uploadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
addLogEntry(uploadLogEntry ~ percentage ~ etaString, ["consoleOnly"]);
|
||||||
|
|
||||||
// What fragment size will be used?
|
// What fragment size will be used?
|
||||||
|
@ -5288,8 +5289,8 @@ class SyncEngine {
|
||||||
ulong end_unix_time = Clock.currTime.toUnixTime();
|
ulong end_unix_time = Clock.currTime.toUnixTime();
|
||||||
auto upload_duration = cast(int)(end_unix_time - start_unix_time);
|
auto upload_duration = cast(int)(end_unix_time - start_unix_time);
|
||||||
dur!"seconds"(upload_duration).split!("hours", "minutes", "seconds")(h, m, s);
|
dur!"seconds"(upload_duration).split!("hours", "minutes", "seconds")(h, m, s);
|
||||||
etaString = format!" | DONE in %02d:%02d:%02d"( h, m, s);
|
etaString = format!"| DONE in %02d:%02d:%02d"( h, m, s);
|
||||||
addLogEntry(uploadLogEntry ~ " 100% " ~ etaString, ["consoleOnly"]);
|
addLogEntry(uploadLogEntry ~ "100% " ~ etaString, ["consoleOnly"]);
|
||||||
|
|
||||||
// Remove session file if it exists
|
// Remove session file if it exists
|
||||||
if (exists(threadUploadSessionFilePath)) {
|
if (exists(threadUploadSessionFilePath)) {
|
||||||
|
|
Loading…
Reference in a new issue