lib/db: Do not reset index-id when dropping device (ref #7135) (#7156)

This reverts commit 641b7aee38.
This commit is contained in:
Simon Frei 2020-11-25 22:54:05 +01:00 committed by GitHub
parent 54b50e3d52
commit 3169212046
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -74,13 +74,6 @@ func (s *FileSet) Drop(device protocol.DeviceID) {
// announced from the remote is newer than our current sequence
// number.
s.meta.resetAll(device)
// Also reset the index ID, as we do want a full index retransfer
// if we ever reconnect, regardless of if the index ID changed.
if err := s.db.setIndexID(device[:], []byte(s.folder), 0); backend.IsClosed(err) {
return
} else if err != nil {
fatalError(err, opStr, s.db)
}
}
t, err := s.db.newReadWriteTransaction()

View File

@ -1741,6 +1741,22 @@ func TestIgnoreLocalChanged(t *testing.T) {
}
}
// Dropping the index ID on Drop is bad, because Drop gets called when receiving
// an Index (as opposed to an IndexUpdate), and we don't want to loose the index
// ID when that happens.
func TestNoIndexIDResetOnDrop(t *testing.T) {
ldb := db.NewLowlevel(backend.OpenMemory())
defer ldb.Close()
s := db.NewFileSet("test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), ldb)
s.SetIndexID(remoteDevice0, 1)
s.Drop(remoteDevice0)
if got := s.IndexID(remoteDevice0); got != 1 {
t.Errorf("Expected unchanged (%v), got %v", 1, got)
}
}
func replace(fs *db.FileSet, device protocol.DeviceID, files []protocol.FileInfo) {
fs.Drop(device)
fs.Update(device, files)