mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-10 01:42:32 +02:00
update pr from master
* update pr from master
This commit is contained in:
commit
e76415155c
20
configure
vendored
20
configure
vendored
|
@ -1,6 +1,6 @@
|
|||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for onedrive v2.4.8.
|
||||
# Generated by GNU Autoconf 2.69 for onedrive v2.4.9-dev.
|
||||
#
|
||||
# Report bugs to <https://github.com/abraunegg/onedrive>.
|
||||
#
|
||||
|
@ -579,8 +579,8 @@ MAKEFLAGS=
|
|||
# Identity of this package.
|
||||
PACKAGE_NAME='onedrive'
|
||||
PACKAGE_TARNAME='onedrive'
|
||||
PACKAGE_VERSION='v2.4.8'
|
||||
PACKAGE_STRING='onedrive v2.4.8'
|
||||
PACKAGE_VERSION='v2.4.9-dev'
|
||||
PACKAGE_STRING='onedrive v2.4.9-dev'
|
||||
PACKAGE_BUGREPORT='https://github.com/abraunegg/onedrive'
|
||||
PACKAGE_URL=''
|
||||
|
||||
|
@ -1219,7 +1219,7 @@ if test "$ac_init_help" = "long"; then
|
|||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures onedrive v2.4.8 to adapt to many kinds of systems.
|
||||
\`configure' configures onedrive v2.4.9-dev to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
|
@ -1280,7 +1280,7 @@ fi
|
|||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of onedrive v2.4.8:";;
|
||||
short | recursive ) echo "Configuration of onedrive v2.4.9-dev:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ fi
|
|||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
onedrive configure v2.4.8
|
||||
onedrive configure v2.4.9-dev
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
@ -1410,7 +1410,7 @@ cat >config.log <<_ACEOF
|
|||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by onedrive $as_me v2.4.8, which was
|
||||
It was created by onedrive $as_me v2.4.9-dev, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
|
@ -2162,7 +2162,7 @@ fi
|
|||
|
||||
|
||||
|
||||
PACKAGE_DATE="November 2020"
|
||||
PACKAGE_DATE="December 2020"
|
||||
|
||||
|
||||
|
||||
|
@ -3159,7 +3159,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
|||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by onedrive $as_me v2.4.8, which was
|
||||
This file was extended by onedrive $as_me v2.4.9-dev, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
|
@ -3212,7 +3212,7 @@ _ACEOF
|
|||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
onedrive config.status v2.4.8
|
||||
onedrive config.status v2.4.9-dev
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ dnl - commit the changed files (configure.ac, configure)
|
|||
dnl - tag the release
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([onedrive],[v2.4.8], [https://github.com/abraunegg/onedrive], [onedrive])
|
||||
AC_INIT([onedrive],[v2.4.9-dev], [https://github.com/abraunegg/onedrive], [onedrive])
|
||||
AC_CONFIG_SRCDIR([src/main.d])
|
||||
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ final class Monitor
|
|||
// catch any error which is generated
|
||||
} catch (std.file.FileException e) {
|
||||
// Standard filesystem error
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
// Issue #1154 handling
|
||||
|
@ -166,7 +166,7 @@ final class Monitor
|
|||
exit(-1);
|
||||
} else {
|
||||
// some other error
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -388,12 +388,4 @@ final class Monitor
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse and display error message received from the local file system
|
||||
private void displayFileSystemErrorMessage(string message)
|
||||
{
|
||||
log.error("ERROR: The local file system returned an error with the following message:");
|
||||
auto errorArray = splitLines(message);
|
||||
log.error(" Error Message: ", errorArray[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import core.thread, std.conv, std.math;
|
|||
import std.algorithm.searching;
|
||||
import progress;
|
||||
import config;
|
||||
import util;
|
||||
static import log;
|
||||
shared bool debugResponse = false;
|
||||
private bool dryRun = false;
|
||||
|
@ -64,7 +65,7 @@ private {
|
|||
string driveByIdUrl = globalGraphEndpoint ~ "/v1.0/drives/";
|
||||
|
||||
// What is 'shared with me' Query
|
||||
string sharedWithMe = globalGraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
string sharedWithMeUrl = globalGraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
|
||||
// What are my 'tenant' details
|
||||
string sharepointTenantId = globalGraphEndpoint ~ "/v1.0/organization";
|
||||
|
@ -206,8 +207,8 @@ final class OneDriveApi
|
|||
siteSearchUrl = usl4GraphEndpoint ~ "/v1.0/sites?search";
|
||||
siteDriveUrl = usl4GraphEndpoint ~ "/v1.0/sites/";
|
||||
// Shared With Me
|
||||
sharedWithMe = usl4GraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
sharepointTenantId = usl4GraphEndpoint ~ "/v1.0/organization";
|
||||
sharedWithMeUrl = usl4GraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
sharepointTenantId = usl4GraphEndpoint ~ "/v1.0/organization";
|
||||
break;
|
||||
case "USL5":
|
||||
log.log("Configuring Azure AD for US Government Endpoints (DOD)");
|
||||
|
@ -233,7 +234,7 @@ final class OneDriveApi
|
|||
siteSearchUrl = usl5GraphEndpoint ~ "/v1.0/sites?search";
|
||||
siteDriveUrl = usl5GraphEndpoint ~ "/v1.0/sites/";
|
||||
// Shared With Me
|
||||
sharedWithMe = usl5GraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
sharedWithMeUrl = usl5GraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
sharepointTenantId = usl5GraphEndpoint ~ "/v1.0/organization";
|
||||
break;
|
||||
case "DE":
|
||||
|
@ -260,7 +261,7 @@ final class OneDriveApi
|
|||
siteSearchUrl = deGraphEndpoint ~ "/v1.0/sites?search";
|
||||
siteDriveUrl = deGraphEndpoint ~ "/v1.0/sites/";
|
||||
// Shared With Me
|
||||
sharedWithMe = deGraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
sharedWithMeUrl = deGraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
sharepointTenantId = deGraphEndpoint ~ "/v1.0/organization";
|
||||
break;
|
||||
case "CN":
|
||||
|
@ -287,7 +288,7 @@ final class OneDriveApi
|
|||
siteSearchUrl = cnGraphEndpoint ~ "/v1.0/sites?search";
|
||||
siteDriveUrl = cnGraphEndpoint ~ "/v1.0/sites/";
|
||||
// Shared With Me
|
||||
sharedWithMe = cnGraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
sharedWithMeUrl = cnGraphEndpoint ~ "/v1.0/me/drive/sharedWithMe";
|
||||
sharepointTenantId = cnGraphEndpoint ~ "/v1.0/organization";
|
||||
break;
|
||||
// Default - all other entries
|
||||
|
@ -295,6 +296,28 @@ final class OneDriveApi
|
|||
log.log("Unknown Azure AD Endpoint request - using Global Azure AD Endpoints");
|
||||
}
|
||||
|
||||
// Debug output of configured URL's
|
||||
// Authentication
|
||||
log.vdebug("Configured authUrl: ", authUrl);
|
||||
log.vdebug("Configured redirectUrl: ", redirectUrl);
|
||||
log.vdebug("Configured tokenUrl: ", tokenUrl);
|
||||
|
||||
// Drive Queries
|
||||
log.vdebug("Configured driveUrl: ", driveUrl);
|
||||
log.vdebug("Configured driveByIdUrl: ", driveByIdUrl);
|
||||
|
||||
// Shared With Me
|
||||
log.vdebug("Configured sharedWithMeUrl: ", sharedWithMeUrl);
|
||||
log.vdebug("Configured sharepointTenantId: ", sharepointTenantId);
|
||||
|
||||
// Item Queries
|
||||
log.vdebug("Configured itemByIdUrl: ", itemByIdUrl);
|
||||
log.vdebug("Configured itemByPathUrl: ", itemByPathUrl);
|
||||
|
||||
// SharePoint Queries
|
||||
log.vdebug("Configured siteSearchUrl: ", siteSearchUrl);
|
||||
log.vdebug("Configured siteDriveUrl: ", siteDriveUrl);
|
||||
|
||||
// Configure the User Agent string
|
||||
if (cfg.getValueString("user_agent") == "") {
|
||||
// Application User Agent string defaults
|
||||
|
@ -417,7 +440,7 @@ final class OneDriveApi
|
|||
response = cast(char[]) read(responseUrl);
|
||||
} catch (OneDriveException e) {
|
||||
// exception generated
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -538,7 +561,7 @@ final class OneDriveApi
|
|||
{
|
||||
checkAccessTokenExpired();
|
||||
const(char)[] url;
|
||||
url = sharedWithMe;
|
||||
url = sharedWithMeUrl;
|
||||
url ~= "?allowexternal=true";
|
||||
return get(url);
|
||||
}
|
||||
|
@ -606,7 +629,7 @@ final class OneDriveApi
|
|||
remove(saveToPath);
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,7 +647,7 @@ final class OneDriveApi
|
|||
newPath.setAttributes(cfg.returnRequiredDirectoryPermisions());
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -856,7 +879,7 @@ final class OneDriveApi
|
|||
}
|
||||
} catch (OneDriveException e) {
|
||||
// an error was generated
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
|
||||
if (response.type() == JSONType.object) {
|
||||
|
@ -876,7 +899,7 @@ final class OneDriveApi
|
|||
cfg.refreshTokenFilePath.setAttributes(cfg.returnRequiredFilePermisions());
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
if (printAccessToken) writeln("New access token: ", accessToken);
|
||||
|
@ -1045,7 +1068,7 @@ final class OneDriveApi
|
|||
writeln();
|
||||
// Reset onProgress to not display anything for next download done using exit scope
|
||||
} catch (CurlException e) {
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
// free progress bar memory
|
||||
p = null;
|
||||
|
@ -1055,7 +1078,7 @@ final class OneDriveApi
|
|||
// try and catch any curl error
|
||||
http.perform();
|
||||
} catch (CurlException e) {
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,10 +1210,11 @@ final class OneDriveApi
|
|||
log.error("ERROR: OneDrive returned an error with the following message:");
|
||||
auto errorArray = splitLines(e.msg);
|
||||
string errorMessage = errorArray[0];
|
||||
string defaultTimeoutErrorMessage = " Error Message: There was a timeout in accessing the Microsoft OneDrive service - Internet connectivity issue?";
|
||||
|
||||
if (canFind(errorMessage, "Couldn't connect to server on handle") || canFind(errorMessage, "Couldn't resolve host name on handle")) {
|
||||
if (canFind(errorMessage, "Couldn't connect to server on handle") || canFind(errorMessage, "Couldn't resolve host name on handle") || canFind(errorMessage, "Timeout was reached on handle")) {
|
||||
// This is a curl timeout
|
||||
log.error(" Error Message: There was a timeout in accessing the Microsoft OneDrive service - Internet connectivity issue?");
|
||||
log.error(defaultTimeoutErrorMessage);
|
||||
// or 408 request timeout
|
||||
// https://github.com/abraunegg/onedrive/issues/694
|
||||
// Back off & retry with incremental delay
|
||||
|
@ -1216,8 +1240,8 @@ final class OneDriveApi
|
|||
log.log("Internet connectivity to Microsoft OneDrive service has been restored");
|
||||
retrySuccess = true;
|
||||
} catch (CurlException e) {
|
||||
if (canFind(e.msg, "Couldn't connect to server on handle") || canFind(e.msg, "Couldn't resolve host name on handle")) {
|
||||
log.error(" Error Message: There was a timeout in accessing the Microsoft OneDrive service - Internet connectivity issue?");
|
||||
if (canFind(e.msg, "Couldn't connect to server on handle") || canFind(e.msg, "Couldn't resolve host name on handle") || canFind(errorMessage, "Timeout was reached on handle")) {
|
||||
log.error(defaultTimeoutErrorMessage);
|
||||
// Increment & loop around
|
||||
retryAttempts++;
|
||||
}
|
||||
|
@ -1235,6 +1259,7 @@ final class OneDriveApi
|
|||
} else {
|
||||
// Some other error was returned
|
||||
log.error(" Error Message: ", errorMessage);
|
||||
log.error(" Calling Function: ", getFunctionName!({}));
|
||||
}
|
||||
// return an empty JSON for handling
|
||||
return json;
|
||||
|
@ -1471,29 +1496,6 @@ final class OneDriveApi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse and display error message received from OneDrive
|
||||
private void displayOneDriveErrorMessage(string message) {
|
||||
log.error("\nERROR: OneDrive returned an error with the following message:");
|
||||
auto errorArray = splitLines(message);
|
||||
log.error(" Error Message: ", errorArray[0]);
|
||||
// Strip cause from error to leave a JSON
|
||||
JSONValue errorMessage = parseJSON(replace(message, errorArray[0], ""));
|
||||
// extra debug
|
||||
log.vdebug("Raw Error Data: ", message);
|
||||
log.vdebug("JSON Message: ", errorMessage);
|
||||
if (errorMessage.type() == JSONType.object) {
|
||||
log.error(" Error Reason: ", errorMessage["error_description"].str);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse and display error message received from the local file system
|
||||
private void displayFileSystemErrorMessage(string message)
|
||||
{
|
||||
log.error("ERROR: The local file system returned an error with the following message:");
|
||||
auto errorArray = splitLines(message);
|
||||
log.error(" Error Message: ", errorArray[0]);
|
||||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
|
|
197
src/sync.d
197
src/sync.d
|
@ -297,7 +297,7 @@ final class SyncEngine
|
|||
log.vdebug("oneDriveDetails = onedrive.getDefaultDrive() generated a OneDriveException");
|
||||
if (e.httpStatusCode == 400) {
|
||||
// OneDrive responded with 400 error: Bad Request
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
|
||||
// Check this
|
||||
if (cfg.getValueString("drive_id").length) {
|
||||
|
@ -308,7 +308,7 @@ final class SyncEngine
|
|||
}
|
||||
if (e.httpStatusCode == 401) {
|
||||
// HTTP request returned status code 401 (Unauthorized)
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
log.errorAndNotify("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n");
|
||||
// Must exit here
|
||||
exit(-1);
|
||||
|
@ -324,7 +324,7 @@ final class SyncEngine
|
|||
}
|
||||
if (e.httpStatusCode >= 500) {
|
||||
// There was a HTTP 5xx Server Side Error
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
// Must exit here
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ final class SyncEngine
|
|||
log.vdebug("oneDriveRootDetails = onedrive.getDefaultRoot() generated a OneDriveException");
|
||||
if (e.httpStatusCode == 400) {
|
||||
// OneDrive responded with 400 error: Bad Request
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
// Check this
|
||||
if (cfg.getValueString("drive_id").length) {
|
||||
log.error("\nERROR: Check your 'drive_id' entry in your configuration file as it may be incorrect\n");
|
||||
|
@ -347,7 +347,7 @@ final class SyncEngine
|
|||
}
|
||||
if (e.httpStatusCode == 401) {
|
||||
// HTTP request returned status code 401 (Unauthorized)
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
log.errorAndNotify("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n");
|
||||
// Must exit here
|
||||
exit(-1);
|
||||
|
@ -363,7 +363,7 @@ final class SyncEngine
|
|||
}
|
||||
if (e.httpStatusCode >= 500) {
|
||||
// There was a HTTP 5xx Server Side Error
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
// Must exit here
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -1355,7 +1355,7 @@ final class SyncEngine
|
|||
// HTTP request returned status code 500 (Internal Server Error)
|
||||
if (e.httpStatusCode == 500) {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1380,13 +1380,13 @@ final class SyncEngine
|
|||
// display what the error is
|
||||
log.vdebug("Query Error: changes = generateDeltaResponse(driveId, idToQuery) on re-try after delay");
|
||||
// error was not a 504 this time
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1396,13 +1396,14 @@ final class SyncEngine
|
|||
try {
|
||||
// Fetch the changes relative to the path id we want to query
|
||||
log.vdebug("Attempting query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)'");
|
||||
log.vdebug("driveId: ", driveId);
|
||||
log.vdebug("idToQuery: ", idToQuery);
|
||||
log.vdebug("deltaLink: ", deltaLink);
|
||||
log.vdebug("driveId: ", driveId);
|
||||
log.vdebug("idToQuery: ", idToQuery);
|
||||
log.vdebug("Previous deltaLink: ", deltaLink);
|
||||
// changes with or without deltaLink
|
||||
changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink);
|
||||
if (changes.type() == JSONType.object) {
|
||||
log.vdebug("Query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)' performed successfully");
|
||||
log.vdebug("OneDrive API /delta response: ", changes);
|
||||
}
|
||||
} catch (OneDriveException e) {
|
||||
// OneDrive threw an error
|
||||
|
@ -1435,7 +1436,7 @@ final class SyncEngine
|
|||
// HTTP request returned status code 500 (Internal Server Error)
|
||||
if (e.httpStatusCode == 500) {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1469,19 +1470,25 @@ final class SyncEngine
|
|||
log.vdebug("Query 'changes = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLink)' performed successfully on re-try");
|
||||
} catch (OneDriveException e) {
|
||||
// Tried 3 times, give up
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// error was not a 504 this time
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||
// Issue #1174 handling where stored deltaLink is invalid
|
||||
if ((e.httpStatusCode == 400) && (deltaLink != "")) {
|
||||
// Set deltaLink to an empty entry so invalid URL is not reused
|
||||
string emptyDeltaLink = "";
|
||||
itemdb.setDeltaLink(driveId, idToQuery, emptyDeltaLink);
|
||||
}
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1534,7 +1541,7 @@ final class SyncEngine
|
|||
// HTTP request returned status code 500 (Internal Server Error)
|
||||
if (e.httpStatusCode == 500) {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1568,19 +1575,19 @@ final class SyncEngine
|
|||
log.vdebug("Query 'changesAvailable = onedrive.viewChangesByItemId(driveId, idToQuery, deltaLinkAvailable)' performed successfully on re-try");
|
||||
} catch (OneDriveException e) {
|
||||
// Tried 3 times, give up
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// error was not a 504 this time
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1806,12 +1813,12 @@ final class SyncEngine
|
|||
log.vlog("Remote change discarded - item cannot be found");
|
||||
} else {
|
||||
// not a 404
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// not a 404 or a 429
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2477,7 +2484,7 @@ final class SyncEngine
|
|||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
// flag that this failed
|
||||
downloadFailed = true;
|
||||
return;
|
||||
|
@ -2539,7 +2546,7 @@ final class SyncEngine
|
|||
setTimes(newPath, newItem.mtime, newItem.mtime);
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2652,7 +2659,7 @@ final class SyncEngine
|
|||
retryAttempts++;
|
||||
}
|
||||
} else {
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2687,7 +2694,7 @@ final class SyncEngine
|
|||
retryAttempts++;
|
||||
}
|
||||
} else {
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2695,13 +2702,13 @@ final class SyncEngine
|
|||
} catch (FileException e) {
|
||||
// There was a file system error
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
downloadFailed = true;
|
||||
return;
|
||||
} catch (std.exception.ErrnoException e) {
|
||||
// There was a file system error
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
downloadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -2720,7 +2727,7 @@ final class SyncEngine
|
|||
setTimes(path, item.mtime, item.mtime);
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
} else {
|
||||
// size error?
|
||||
|
@ -2836,7 +2843,7 @@ final class SyncEngine
|
|||
rmdirRecurse(path);
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3387,14 +3394,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -3424,14 +3431,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -3482,14 +3489,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -3544,14 +3551,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -3880,7 +3887,7 @@ final class SyncEngine
|
|||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -4055,7 +4062,7 @@ final class SyncEngine
|
|||
} else {
|
||||
// some other error from OneDrive was returned - display what it is
|
||||
log.error("OneDrive generated an error when creating this path: ", path);
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -4291,14 +4298,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4348,7 +4355,7 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4356,14 +4363,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4398,14 +4405,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4441,14 +4448,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4636,7 +4643,7 @@ final class SyncEngine
|
|||
// error uploading file
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4644,14 +4651,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4690,14 +4697,14 @@ final class SyncEngine
|
|||
// error uploading file
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4772,14 +4779,14 @@ final class SyncEngine
|
|||
// error uploading file
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4809,14 +4816,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -4838,14 +4845,14 @@ final class SyncEngine
|
|||
} else {
|
||||
// display what the error is
|
||||
writeln("skipped.");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
} catch (FileException e) {
|
||||
// display the error message
|
||||
writeln("skipped.");
|
||||
displayFileSystemErrorMessage(e.msg);
|
||||
displayFileSystemErrorMessage(e.msg, getFunctionName!({}));
|
||||
uploadFailed = true;
|
||||
return;
|
||||
}
|
||||
|
@ -5011,7 +5018,7 @@ final class SyncEngine
|
|||
} catch (OneDriveException e) {
|
||||
// display what the error is
|
||||
log.vdebug("A further error was generated when attempting a reverse delete of objects from OneDrive");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -5039,7 +5046,7 @@ final class SyncEngine
|
|||
} catch (OneDriveException e) {
|
||||
// display what the error is
|
||||
log.vdebug("A further error was generated when attempting a reverse delete of objects from OneDrive");
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -5047,7 +5054,7 @@ final class SyncEngine
|
|||
// Not a 403 response & OneDrive Business Account / O365 Shared Folder / Library
|
||||
log.vdebug("onedrive.deleteById generated an error response when attempting to delete object by item id");
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -5129,34 +5136,6 @@ final class SyncEngine
|
|||
}
|
||||
}
|
||||
|
||||
// Parse and display error message received from OneDrive
|
||||
private void displayOneDriveErrorMessage(string message)
|
||||
{
|
||||
log.error("\nERROR: OneDrive returned an error with the following message:");
|
||||
auto errorArray = splitLines(message);
|
||||
log.error(" Error Message: ", errorArray[0]);
|
||||
// extract 'message' as the reason
|
||||
JSONValue errorMessage = parseJSON(replace(message, errorArray[0], ""));
|
||||
string errorReason = errorMessage["error"]["message"].str;
|
||||
// display reason
|
||||
if (errorReason.startsWith("<!DOCTYPE")) {
|
||||
// a HTML Error Reason was given
|
||||
log.error(" Error Reason: A HTML Error response was provided. Use debug logging (--verbose --verbose) to view.");
|
||||
log.vdebug(errorReason);
|
||||
} else {
|
||||
// a non HTML Error Reason was given
|
||||
log.error(" Error Reason: ", errorReason);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse and display error message received from the local file system
|
||||
private void displayFileSystemErrorMessage(string message)
|
||||
{
|
||||
log.error("ERROR: The local file system returned an error with the following message:");
|
||||
auto errorArray = splitLines(message);
|
||||
log.error(" Error Message: ", errorArray[0]);
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_move
|
||||
// This function is only called in monitor mode when an move event is coming from
|
||||
// inotify and we try to move the item.
|
||||
|
@ -5303,7 +5282,7 @@ final class SyncEngine
|
|||
log.log(e.msg);
|
||||
} else {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5362,7 +5341,7 @@ final class SyncEngine
|
|||
return;
|
||||
} else {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -5386,7 +5365,7 @@ final class SyncEngine
|
|||
} catch (OneDriveException e) {
|
||||
log.error("ERROR: Query of OneDrive for Office Site ID failed");
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5465,7 +5444,7 @@ final class SyncEngine
|
|||
return;
|
||||
} else {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -5520,7 +5499,7 @@ final class SyncEngine
|
|||
fileDetails = onedrive.getFileDetails(item.driveId, item.id);
|
||||
} catch (OneDriveException e) {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5586,7 +5565,7 @@ final class SyncEngine
|
|||
return;
|
||||
} else {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -5643,10 +5622,10 @@ final class SyncEngine
|
|||
// OneDrive threw an error
|
||||
log.vdebug("Error query: changes = onedrive.viewChangesById(driveId, idToQuery, deltaLink)");
|
||||
log.vdebug("OneDrive threw an error when querying for these changes:");
|
||||
log.vdebug("driveId: ", driveId);
|
||||
log.vdebug("idToQuery: ", idToQuery);
|
||||
log.vdebug("deltaLink: ", deltaLink);
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
log.vdebug("driveId: ", driveId);
|
||||
log.vdebug("idToQuery: ", idToQuery);
|
||||
log.vdebug("Previous deltaLink: ", deltaLink);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -5873,7 +5852,7 @@ final class SyncEngine
|
|||
driveData = onedrive.getPathDetailsById(driveId, idToQuery);
|
||||
} else {
|
||||
// There was a HTTP 5xx Server Side Error
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
// Must exit here
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -5901,7 +5880,7 @@ final class SyncEngine
|
|||
|
||||
} else {
|
||||
// There was a HTTP 5xx Server Side Error
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
// Must exit here
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -5945,7 +5924,7 @@ final class SyncEngine
|
|||
// HTTP request returned status code 500 (Internal Server Error)
|
||||
if (e.httpStatusCode == 500) {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
|
||||
// HTTP request returned status code 504 (Gateway Timeout) or 429 retry
|
||||
|
@ -5967,12 +5946,12 @@ final class SyncEngine
|
|||
// display what the error is
|
||||
log.vdebug("Query Error: topLevelChildren = onedrive.listChildren(driveId, idToQuery, nextLink) on re-try after delay");
|
||||
// error was not a 504 this time
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
} else {
|
||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6056,7 +6035,7 @@ final class SyncEngine
|
|||
// HTTP request returned status code 500 (Internal Server Error)
|
||||
if (e.httpStatusCode == 500) {
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
|
||||
// HTTP request returned status code 504 (Gateway Timeout) or 429 retry
|
||||
|
@ -6078,12 +6057,12 @@ final class SyncEngine
|
|||
// display what the error is
|
||||
log.vdebug("Query Error: thisLevelChildren = onedrive.listChildren(driveId, idToQuery, nextLink) on re-try after delay");
|
||||
// error was not a 504 this time
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
} else {
|
||||
// Default operation if not 404, 410, 429, 500 or 504 errors
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
15
src/upload.d
15
src/upload.d
|
@ -211,7 +211,7 @@ struct UploadSession
|
|||
// insert a new line as well, so that the below error is inserted on the console in the right location
|
||||
log.vlog("\nFragment upload failed - received an exception response from OneDrive");
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
// retry fragment upload in case error is transient
|
||||
log.vlog("Retrying fragment upload");
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ struct UploadSession
|
|||
// OneDrive threw another error on retry
|
||||
log.vlog("Retry to upload fragment failed");
|
||||
// display what the error is
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
displayOneDriveErrorMessage(e.msg, getFunctionName!({}));
|
||||
// set response to null as the fragment upload was in error twice
|
||||
response = null;
|
||||
}
|
||||
|
@ -268,16 +268,7 @@ struct UploadSession
|
|||
}
|
||||
}
|
||||
|
||||
// Parse and display error message received from OneDrive
|
||||
private void displayOneDriveErrorMessage(string message) {
|
||||
log.error("ERROR: OneDrive returned an error with the following message:");
|
||||
auto errorArray = splitLines(message);
|
||||
log.error(" Error Message: ", errorArray[0]);
|
||||
// extract 'message' as the reason
|
||||
JSONValue errorMessage = parseJSON(replace(message, errorArray[0], ""));
|
||||
log.error(" Error Reason: ", errorMessage["error"]["message"].str);
|
||||
}
|
||||
|
||||
// save session details to temp file
|
||||
private void save()
|
||||
{
|
||||
std.file.write(sessionFilePath, session.toString());
|
||||
|
|
89
src/util.d
89
src/util.d
|
@ -11,6 +11,8 @@ import std.stdio;
|
|||
import std.string;
|
||||
import std.algorithm;
|
||||
import std.uri;
|
||||
import std.json;
|
||||
import std.traits;
|
||||
import qxor;
|
||||
static import log;
|
||||
|
||||
|
@ -247,6 +249,93 @@ bool containsASCIIHTMLCodes(string path)
|
|||
return m.empty;
|
||||
}
|
||||
|
||||
// Parse and display error message received from OneDrive
|
||||
void displayOneDriveErrorMessage(string message, string callingFunction)
|
||||
{
|
||||
log.error("\nERROR: Microsoft OneDrive API returned an error with the following message:");
|
||||
auto errorArray = splitLines(message);
|
||||
log.error(" Error Message: ", errorArray[0]);
|
||||
// Extract 'message' as the reason
|
||||
JSONValue errorMessage = parseJSON(replace(message, errorArray[0], ""));
|
||||
// extra debug
|
||||
log.vdebug("Raw Error Data: ", message);
|
||||
log.vdebug("JSON Message: ", errorMessage);
|
||||
|
||||
// What is the reason for the error
|
||||
if (errorMessage.type() == JSONType.object) {
|
||||
// configure the error reason
|
||||
string errorReason;
|
||||
string requestDate;
|
||||
string requestId;
|
||||
|
||||
// set the reason for the error
|
||||
try {
|
||||
// Use error_description as reason
|
||||
errorReason = errorMessage["error_description"].str;
|
||||
} catch (JSONException e) {
|
||||
// we dont want to do anything here
|
||||
}
|
||||
|
||||
// set the reason for the error
|
||||
try {
|
||||
// Use ["error"]["message"] as reason
|
||||
errorReason = errorMessage["error"]["message"].str;
|
||||
} catch (JSONException e) {
|
||||
// we dont want to do anything here
|
||||
}
|
||||
|
||||
// Display the error reason
|
||||
if (errorReason.startsWith("<!DOCTYPE")) {
|
||||
// a HTML Error Reason was given
|
||||
log.error(" Error Reason: A HTML Error response was provided. Use debug logging (--verbose --verbose) to view this error");
|
||||
log.vdebug(errorReason);
|
||||
} else {
|
||||
// a non HTML Error Reason was given
|
||||
log.error(" Error Reason: ", errorReason);
|
||||
}
|
||||
|
||||
// Get the date of request if available
|
||||
try {
|
||||
// Use ["error"]["innerError"]["date"] as date
|
||||
requestDate = errorMessage["error"]["innerError"]["date"].str;
|
||||
} catch (JSONException e) {
|
||||
// we dont want to do anything here
|
||||
}
|
||||
|
||||
// Get the request-id if available
|
||||
try {
|
||||
// Use ["error"]["innerError"]["request-id"] as request-id
|
||||
requestId = errorMessage["error"]["innerError"]["request-id"].str;
|
||||
} catch (JSONException e) {
|
||||
// we dont want to do anything here
|
||||
}
|
||||
|
||||
// Display the date and request id if available
|
||||
if (requestDate != "") log.error(" Error Timestamp: ", requestDate);
|
||||
if (requestId != "") log.error(" API Request ID: ", requestId);
|
||||
}
|
||||
|
||||
// Where in the code was this error generated
|
||||
log.error(" Calling Function: ", callingFunction);
|
||||
}
|
||||
|
||||
// Parse and display error message received from the local file system
|
||||
void displayFileSystemErrorMessage(string message, string callingFunction)
|
||||
{
|
||||
log.error("ERROR: The local file system returned an error with the following message:");
|
||||
auto errorArray = splitLines(message);
|
||||
// What was the error message
|
||||
log.error(" Error Message: ", errorArray[0]);
|
||||
// Where in the code was this error generated
|
||||
log.error(" Calling Function: ", callingFunction);
|
||||
}
|
||||
|
||||
// Get the function name that is being called to assist with identifying where an error is being generated
|
||||
string getFunctionName(alias func)() {
|
||||
return __traits(identifier, __traits(parent, func)) ~ "()\n";
|
||||
}
|
||||
|
||||
// Unit Tests
|
||||
unittest
|
||||
{
|
||||
assert(multiGlobMatch(".hidden", ".*"));
|
||||
|
|
Loading…
Reference in a new issue