From 44bdaf3ac27ac1dfd25d4516d7a73fe159953eae Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 26 Dec 2016 13:48:54 +0100 Subject: [PATCH] cmd/syncthing: Add -reset-deltas option to reset delta index IDs Also rename and clarify the description of -reset-database (formerly -reset). --- cmd/syncthing/main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index ba25c30f4..8619367cd 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -199,7 +199,8 @@ var ( type RuntimeOptions struct { confDir string - reset bool + resetDatabase bool + resetDeltaIdxs bool showVersion bool showPaths bool doUpgrade bool @@ -260,7 +261,8 @@ func parseCommandLineOptions() RuntimeOptions { flag.BoolVar(&options.noBrowser, "no-browser", false, "Do not start browser") flag.BoolVar(&options.browserOnly, "browser-only", false, "Open GUI in browser") flag.BoolVar(&options.noRestart, "no-restart", options.noRestart, "Do not restart; just exit") - flag.BoolVar(&options.reset, "reset", false, "Reset the database") + flag.BoolVar(&options.resetDatabase, "reset-database", false, "Reset the database, forcing a full rescan and resync") + flag.BoolVar(&options.resetDeltaIdxs, "reset-deltas", false, "Reset delta index IDs, forcing a full index exchange") flag.BoolVar(&options.doUpgrade, "upgrade", false, "Perform upgrade") flag.BoolVar(&options.doUpgradeCheck, "upgrade-check", false, "Check for available upgrade") flag.BoolVar(&options.showVersion, "version", false, "Show version") @@ -369,7 +371,7 @@ func main() { return } - if options.reset { + if options.resetDatabase { resetDB() return } @@ -669,6 +671,11 @@ func syncthingMain(runtimeOptions RuntimeOptions) { l.Fatalln("Cannot open database:", err, "- Is another copy of Syncthing already running?") } + if runtimeOptions.resetDeltaIdxs { + l.Infoln("Reinitializing delta index IDs") + ldb.DropDeltaIndexIDs() + } + protectedFiles := []string{ locations[locDatabase], locations[locConfigFile],