mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-10 09:46:40 +02:00
* Catch uphandled MonitorException when inotify throws an error * Change monitor loop init full scan to false at start as fullScanOverride now correctly handled, negating need to true-up at application start * Handle '100 Continue' response during upload * Update handling of delta link being expired * Update progress bar handling for uploads as #888 changed bar dynamics
This commit is contained in:
parent
eda3d3c4bb
commit
cb06395a46
21
src/main.d
21
src/main.d
|
@ -765,7 +765,7 @@ int main(string[] args)
|
|||
auto lastCheckTime = MonoTime.currTime();
|
||||
auto logMonitorCounter = 0;
|
||||
auto fullScanCounter = 0;
|
||||
bool fullScanRequired = true;
|
||||
bool fullScanRequired = false;
|
||||
bool syncListConfiguredFullScanOverride = false;
|
||||
// if sync list is configured, set to true
|
||||
if (syncListConfigured) {
|
||||
|
@ -774,7 +774,15 @@ int main(string[] args)
|
|||
}
|
||||
|
||||
while (true) {
|
||||
if (!cfg.getValueBool("download_only")) m.update(online);
|
||||
if (!cfg.getValueBool("download_only")) {
|
||||
try {
|
||||
m.update(online);
|
||||
} catch (MonitorException e) {
|
||||
// Catch any exceptions thrown by inotify / monitor engine
|
||||
log.error("ERROR: The following inotify error was generated: ", e.msg);
|
||||
}
|
||||
}
|
||||
|
||||
auto currTime = MonoTime.currTime();
|
||||
if (currTime - lastCheckTime > checkInterval) {
|
||||
// log monitor output suppression
|
||||
|
@ -813,7 +821,12 @@ int main(string[] args)
|
|||
performSync(sync, cfg.getValueString("single_directory"), cfg.getValueBool("download_only"), cfg.getValueBool("local_first"), cfg.getValueBool("upload_only"), (logMonitorCounter == logInterval ? MONITOR_LOG_QUIET : MONITOR_LOG_SILENT), fullScanRequired, syncListConfiguredFullScanOverride);
|
||||
if (!cfg.getValueBool("download_only")) {
|
||||
// discard all events that may have been generated by the sync
|
||||
m.update(false);
|
||||
try {
|
||||
m.update(false);
|
||||
} catch (MonitorException e) {
|
||||
// Catch any exceptions thrown by inotify / monitor engine
|
||||
log.error("ERROR: The following inotify error was generated: ", e.msg);
|
||||
}
|
||||
}
|
||||
} catch (CurlException e) {
|
||||
// we already tried three times in the performSync routine
|
||||
|
@ -974,7 +987,7 @@ void performSync(SyncEngine sync, string singleDirectory, bool downloadOnly, boo
|
|||
// --synchronize & no sync_list : fullScanRequired = false, syncListConfiguredFullScanOverride = false
|
||||
// --synchronize & sync_list in use : fullScanRequired = false, syncListConfiguredFullScanOverride = true
|
||||
|
||||
// --monitor loops around 10 iterations. On the 1st loop, sets fullScanRequired = true, syncListConfiguredFullScanOverride = true if requried
|
||||
// --monitor loops around 10 iterations. On the 1st loop, sets fullScanRequired = false, syncListConfiguredFullScanOverride = true if requried
|
||||
|
||||
// --monitor & no sync_list (loop #1) : fullScanRequired = true, syncListConfiguredFullScanOverride = false
|
||||
// --monitor & no sync_list (loop #2 - #10) : fullScanRequired = false, syncListConfiguredFullScanOverride = false
|
||||
|
|
|
@ -810,7 +810,7 @@ final class OneDriveApi
|
|||
Errors in the OneDrive API are returned using standard HTTP status codes, as well as a JSON error response object. The following HTTP status codes should be expected.
|
||||
|
||||
Status code Status message Description
|
||||
|
||||
100 Continue Continue
|
||||
200 OK Request was handled OK
|
||||
201 Created This means you've made a successful POST to checkout, lock in a format, or place a hold
|
||||
204 No Content This means you've made a successful DELETE to remove a hold or return a title
|
||||
|
@ -850,6 +850,9 @@ final class OneDriveApi
|
|||
// 0 - OK ... HTTP2 version of 200 OK
|
||||
case 0:
|
||||
break;
|
||||
// 100 - Continue
|
||||
case 100:
|
||||
break;
|
||||
// 200 - OK
|
||||
case 200:
|
||||
// No Log ..
|
||||
|
@ -953,6 +956,9 @@ final class OneDriveApi
|
|||
// 0 - OK ... HTTP2 version of 200 OK
|
||||
case 0:
|
||||
break;
|
||||
// 100 - Continue
|
||||
case 100:
|
||||
break;
|
||||
// 200 - OK
|
||||
case 200:
|
||||
// No Log ..
|
||||
|
|
14
src/sync.d
14
src/sync.d
|
@ -939,7 +939,7 @@ final class SyncEngine
|
|||
|
||||
// HTTP request returned status code 410 (The requested resource is no longer available at the server)
|
||||
if (e.httpStatusCode == 410) {
|
||||
log.vlog("Delta link expired, re-syncing...");
|
||||
log.vdebug("Delta link expired for 'onedrive.viewChangesById(driveId, idToQuery, deltaLink)', setting 'deltaLink = null'");
|
||||
deltaLink = null;
|
||||
continue;
|
||||
}
|
||||
|
@ -983,7 +983,8 @@ final class SyncEngine
|
|||
log.vdebug("changes = onedrive.viewChangesById(driveId, idToQuery, deltaLink) previously threw an error - retrying with empty deltaLink");
|
||||
try {
|
||||
// try query with empty deltaLink value
|
||||
changes = onedrive.viewChangesById(driveId, idToQuery, "");
|
||||
deltaLink = null;
|
||||
changes = onedrive.viewChangesById(driveId, idToQuery, deltaLink);
|
||||
log.vdebug("Query 'changes = onedrive.viewChangesById(driveId, idToQuery, deltaLink)' performed successfully on re-try");
|
||||
} catch (OneDriveException e) {
|
||||
// Tried 3 times, give up
|
||||
|
@ -1031,8 +1032,8 @@ final class SyncEngine
|
|||
|
||||
// HTTP request returned status code 410 (The requested resource is no longer available at the server)
|
||||
if (e.httpStatusCode == 410) {
|
||||
log.vlog("Delta link expired, re-syncing...");
|
||||
deltaLink = null;
|
||||
log.vdebug("Delta link expired for 'onedrive.viewChangesById(driveId, idToQuery, deltaLinkAvailable)', setting 'deltaLinkAvailable = null'");
|
||||
deltaLinkAvailable = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1074,8 +1075,9 @@ final class SyncEngine
|
|||
log.log("OneDrive returned a 'HTTP 504 - Gateway Timeout' when attempting to query for changes - retrying applicable request");
|
||||
log.vdebug("changesAvailable = onedrive.viewChangesById(driveId, idToQuery, deltaLinkAvailable) previously threw an error - retrying with empty deltaLinkAvailable");
|
||||
try {
|
||||
// try query with empty deltaLink value
|
||||
changesAvailable = onedrive.viewChangesById(driveId, idToQuery, "");
|
||||
// try query with empty deltaLinkAvailable value
|
||||
deltaLinkAvailable = null;
|
||||
changesAvailable = onedrive.viewChangesById(driveId, idToQuery, deltaLinkAvailable);
|
||||
log.vdebug("Query 'changesAvailable = onedrive.viewChangesById(driveId, idToQuery, deltaLinkAvailable)' performed successfully on re-try");
|
||||
} catch (OneDriveException e) {
|
||||
// Tried 3 times, give up
|
||||
|
|
|
@ -174,6 +174,9 @@ struct UploadSession
|
|||
p.title = "Uploading";
|
||||
long fragmentCount = 0;
|
||||
|
||||
// Initialise the download bar at 0%
|
||||
p.next();
|
||||
|
||||
while (true) {
|
||||
fragmentCount++;
|
||||
log.vdebugNewLine("Fragment: ", fragmentCount, " of ", iteration);
|
||||
|
@ -189,6 +192,10 @@ struct UploadSession
|
|||
fileSize
|
||||
);
|
||||
} catch (OneDriveException e) {
|
||||
// if a 100 response is generated, continue
|
||||
if (e.httpStatusCode == 100) {
|
||||
continue;
|
||||
}
|
||||
// there was an error response from OneDrive when uploading the file fragment
|
||||
// handle 'HTTP request returned status code 429 (Too Many Requests)' first
|
||||
if (e.httpStatusCode == 429) {
|
||||
|
|
Loading…
Reference in a new issue