mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-08 08:46:40 +02:00
* 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:
parent
7c2b3e853d
commit
ea2e4a98bf
|
@ -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 != ""){
|
||||
|
|
26
src/sync.d
26
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 {
|
||||
|
|
Loading…
Reference in a new issue