diff --git a/src/main.d b/src/main.d index 32c1d733..23f58801 100644 --- a/src/main.d +++ b/src/main.d @@ -728,6 +728,11 @@ void performSync(SyncEngine sync, string singleDirectory, bool downloadOnly, boo localPath = singleDirectory; } + // Due to Microsoft Sharepoint 'enrichment' of files, we try to download the Microsoft modified file automatically + // Set flag if we are in upload only state to handle this differently + // See: https://github.com/OneDrive/onedrive-api-docs/issues/935 for further details + if (uploadOnly) sync.setUploadOnly(); + do { try { if (singleDirectory != ""){ diff --git a/src/sync.d b/src/sync.d index 4291d171..bb29f954 100644 --- a/src/sync.d +++ b/src/sync.d @@ -17,6 +17,9 @@ private long thresholdFileSize = 4 * 2^^20; // 4 MiB // flag to set whether local files should be deleted private bool noRemoteDelete = false; +// flag to set if we are running as uploadOnly +private bool uploadOnly = false; + // Do we configure to disable the upload validation routine private bool disableUploadValidation = false; @@ -299,6 +302,13 @@ final class SyncEngine noRemoteDelete = true; } + // Configure uploadOnly if function is called + // By default, uploadOnly = false; + void setUploadOnly() + { + uploadOnly = true; + } + // Configure disableUploadValidation if function is called // By default, disableUploadValidation = false; // Meaning we will always validate our uploads @@ -1929,11 +1939,17 @@ final class SyncEngine saveItem(response); // Due to https://github.com/OneDrive/onedrive-api-docs/issues/935 Microsoft modifies all PDF, MS Office & HTML files with added XML content. It is a 'feature' of SharePoint. // So - now the 'local' and 'remote' file is technically DIFFERENT ... thanks Microsoft .. NO way to disable this stupidity - // Download the Microsoft 'modified' file so 'local' is now in sync - log.vlog("Due to Microsoft Sharepoint 'enrichment' of files, downloading 'enriched' file to ensure local file is in-sync"); - log.vlog("See: https://github.com/OneDrive/onedrive-api-docs/issues/935 for further details"); - auto fileSize = response["size"].integer; - onedrive.downloadById(response["parentReference"]["driveId"].str, response["id"].str, path, fileSize); + if(!uploadOnly){ + // Download the Microsoft 'modified' file so 'local' is now in sync + log.vlog("Due to Microsoft Sharepoint 'enrichment' of files, downloading 'enriched' file to ensure local file is in-sync"); + log.vlog("See: https://github.com/OneDrive/onedrive-api-docs/issues/935 for further details"); + auto fileSize = response["size"].integer; + onedrive.downloadById(response["parentReference"]["driveId"].str, response["id"].str, path, fileSize); + } else { + // we are not downloading a file, warn that file differences will exist + log.vlog("WARNING: Due to Microsoft Sharepoint 'enrichment' of files, this file is now technically different to your local copy"); + log.vlog("See: https://github.com/OneDrive/onedrive-api-docs/issues/935 for further details"); + } } } } else {