Implement Feature Request #49

* Implement --no-remote-delete so that local deletes are not processed to delete the coresponding file on OneDrive when using --upload-only
This commit is contained in:
abraunegg 2018-08-02 07:30:06 +10:00
parent 686da27e34
commit 7667288920
2 changed files with 12 additions and 1 deletions

View file

@ -58,6 +58,8 @@ int main(string[] args)
bool uploadOnly;
// Add a check mounts option to resolve https://github.com/abraunegg/onedrive/issues/8
bool checkMount;
// Add option for no remote delete
bool noRemoteDelete;
try {
auto opt = getopt(
@ -73,6 +75,7 @@ int main(string[] args)
"local-first", "Synchronize from the local directory source first, before downloading changes from OneDrive.", &localFirst,
"logout", "Logout the current user", &logout,
"monitor|m", "Keep monitoring for local and remote changes", &monitor,
"no-remote-delete", "Do not delete local file 'deletes' from OneDrive when using --upload-only", &noRemoteDelete,
"print-token", "Print the access token, useful for debugging", &printAccessToken,
"resync", "Forget the last saved state, perform a full sync", &resync,
"remove-directory", "Remove a directory on OneDrive - no sync will be performed.", &removeDirectory,
@ -119,6 +122,9 @@ int main(string[] args)
// command line parameters override the config
if (syncDirName) cfg.setValue("sync_dir", syncDirName.expandTilde().absolutePath());
// we should only set noRemoteDelete in an upload-only scenario
if ((uploadOnly)&&(noRemoteDelete)) cfg.setValue("no-remote-delete", "true");
// upgrades
if (exists(configDirName ~ "/items.db")) {

View file

@ -910,7 +910,12 @@ final class SyncEngine
}
} else {
log.vlog("The file has been deleted locally");
uploadDeleteItem(item, path);
if (cfg.getValue("no-remote-delete") == "true") {
// do not process remote delete
log.vlog("Skipping remote delete as --upload-only & --no-remote-delete configured");
} else {
uploadDeleteItem(item, path);
}
}
}