cmd/syncthing: Add -reset-deltas option to reset delta index IDs

Also rename and clarify the description of -reset-database (formerly
-reset).
This commit is contained in:
Jakob Borg 2016-12-26 13:48:54 +01:00
parent fc16e49cb0
commit 44bdaf3ac2
1 changed files with 10 additions and 3 deletions

View File

@ -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],