Add --upload-only check for sharepoint fix (Issue #452) (#453)

* Add a check for --upload-only use when trying to work around https://github.com/OneDrive/onedrive-api-docs/issues/935
* Update logging and print a warning message that the files are now technically different due to sharepoint bug and using --upload-only
This commit is contained in:
abraunegg 2019-04-06 12:44:51 +11:00 committed by GitHub
parent 7c2b3e853d
commit ea2e4a98bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 5 deletions

View file

@ -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 != ""){

View file

@ -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 {