lib/db: Catch unignored/conflicting files as needed (fixes #5053) (#5054)

This commit is contained in:
Simon Frei
2018-07-10 17:32:34 +02:00
committed by Jakob Borg
parent e10d7260c2
commit 3f17bda786
3 changed files with 68 additions and 39 deletions

View File

@@ -20,10 +20,11 @@ import (
// 2: v0.14.48
// 3: v0.14.49
// 4: v0.14.49
// 5: v0.14.50
// 5: v0.14.49
// 6: v0.14.50
const (
dbVersion = 5
dbMinSyncthingVersion = "v0.14.49"
dbVersion = 6
dbMinSyncthingVersion = "v0.14.50"
)
type databaseDowngradeError struct {
@@ -62,12 +63,12 @@ func (db *Instance) updateSchema() error {
if prevVersion < 3 {
db.updateSchema2to3()
}
// This update fixes a problem that only exists in dbVersion 3.
if prevVersion == 3 {
db.updateSchema3to4()
// This update fixes problems existing in versions 3 and 4
if prevVersion == 3 || prevVersion == 4 {
db.updateSchemaTo5()
}
if prevVersion < 5 {
db.updateSchema4to5()
if prevVersion < 6 {
db.updateSchema5to6()
}
miscDB.PutInt64("dbVersion", dbVersion)
@@ -192,10 +193,11 @@ func (db *Instance) updateSchema2to3() {
}
}
// updateSchema3to4 resets the need bucket due a bug existing in dbVersion 3 /
// v0.14.49-rc.1
// updateSchemaTo5 resets the need bucket due to bugs existing in the v0.14.49
// release candidates (dbVersion 3 and 4)
// https://github.com/syncthing/syncthing/issues/5007
func (db *Instance) updateSchema3to4() {
// https://github.com/syncthing/syncthing/issues/5053
func (db *Instance) updateSchemaTo5() {
t := db.newReadWriteTransaction()
var nk []byte
for _, folderStr := range db.ListFolders() {
@@ -207,7 +209,7 @@ func (db *Instance) updateSchema3to4() {
db.updateSchema2to3()
}
func (db *Instance) updateSchema4to5() {
func (db *Instance) updateSchema5to6() {
// For every local file with the Invalid bit set, clear the Invalid bit and
// set LocalFlags = FlagLocalIgnored.