From 1cfe137a92e11d29d544581792b60434dc2540a2 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sun, 17 Jun 2018 08:27:43 +1000 Subject: [PATCH 1/2] Implement feature request: Detect when sync-folder is missing * Provide a new switch 'check-mount' which will check for the presence of a hidden file '.nosync' file. If this file is found in the sync dir, then the sync process will shutdown. Refer to #8 for further details. --- src/main.d | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.d b/src/main.d index 6fc5bdb8..4e16a1d6 100644 --- a/src/main.d +++ b/src/main.d @@ -56,12 +56,15 @@ int main(string[] args) bool localFirst; // Upload Only bool uploadOnly; + // Add a check mounts option to resolve https://github.com/abraunegg/onedrive/issues/8 + bool checkMount; try { auto opt = getopt( args, std.getopt.config.bundling, std.getopt.config.caseSensitive, + "check-mount", "Check for the presence of .nosync in the syncdir root", &checkMount, "confdir", "Set the directory used to store the configuration files", &configDirName, "create-directory", "Create a directory on OneDrive - no sync will be performed.", &createDirectory, "destination-directory", "Destination directory for renamed or move on OneDrive - no sync will be performed.", &destinationDirectory, @@ -190,7 +193,17 @@ int main(string[] args) log.log("Initializing the Synchronization Engine ..."); auto sync = new SyncEngine(cfg, onedrive, itemdb, selectiveSync); sync.init(); - + + // Do we need to validate the syncDir to check for the presence of a '.nosync' file + if (checkMount) { + // we were asked to check the mounts + if (exists(syncDir ~ "/.nosync")) { + log.log("\nERROR: .nosync file found. Aborting synchronization process to safeguard data."); + onedrive.http.shutdown(); + return EXIT_FAILURE; + } + } + // Do we need to create or remove a directory? if ((createDirectory != "") || (removeDirectory != "")) { From 77ac29acdf7f0af9e93d9fb8eb5b7fd0d6dbda7f Mon Sep 17 00:00:00 2001 From: abraunegg Date: Wed, 27 Jun 2018 06:23:17 +1000 Subject: [PATCH 2/2] Update feature flag * Update feature flag from 'check-mount' to 'check-for-nomount' as this is what this option does * Add information into readme file --- README.md | 1 + src/main.d | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8006a770..4e1135d5 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,7 @@ If you encounter any bugs you can report them here on Github. Before filing an i Usage: onedrive [OPTION]... no option No Sync and exit + --check-for-nomount Check for the presence of .nosync in the syncdir root. If found, do not perform sync. --confdir Set the directory used to store the configuration files --create-directory Create a directory on OneDrive - no sync will be performed. --destination-directory Destination directory for renamed or move on OneDrive - no sync will be performed. diff --git a/src/main.d b/src/main.d index 4e16a1d6..6077950b 100644 --- a/src/main.d +++ b/src/main.d @@ -64,7 +64,7 @@ int main(string[] args) args, std.getopt.config.bundling, std.getopt.config.caseSensitive, - "check-mount", "Check for the presence of .nosync in the syncdir root", &checkMount, + "check-for-nomount", "Check for the presence of .nosync in the syncdir root. If found, do not perform sync.", &checkMount, "confdir", "Set the directory used to store the configuration files", &configDirName, "create-directory", "Create a directory on OneDrive - no sync will be performed.", &createDirectory, "destination-directory", "Destination directory for renamed or move on OneDrive - no sync will be performed.", &destinationDirectory,