lib/db: Refactor away the large genericReplace thing
This removes a significant, complex chunk of database code. The "replace" operation walked both the old and new in lockstep and made the relevant changes to make the new situation correct. But since delta indexes we pretty much never need this - we just used replace to drop the existing data and start over. This makes that explicit and removes the complexity. (This is one of those things that would be annoying to make case insensitive, while the actual "drop and then insert" that we do is easier.) This is fairly well unit tested... The one change to the tests is to cover the fact that previously replace with something identical didn't bump the sequence number, while obviously removing everything and re-inserting does. This is not behavior we depend on anywhere. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4500 LGTM: imsodin, AudriusButkevicius
This commit is contained in:
committed by
Audrius Butkevicius
parent
57d5dfa80c
commit
d7d45d8092
@@ -2084,8 +2084,10 @@ func TestIndexesForUnknownDevicesDropped(t *testing.T) {
|
||||
dbi := db.OpenMemory()
|
||||
|
||||
files := db.NewFileSet("default", defaultFs, dbi)
|
||||
files.Replace(device1, genFiles(1))
|
||||
files.Replace(device2, genFiles(1))
|
||||
files.Drop(device1)
|
||||
files.Update(device1, genFiles(1))
|
||||
files.Drop(device2)
|
||||
files.Update(device2, genFiles(1))
|
||||
|
||||
if len(files.ListDevices()) != 2 {
|
||||
t.Error("expected two devices")
|
||||
|
||||
Reference in New Issue
Block a user