This commit is contained in:
@@ -951,6 +951,49 @@ func TestDuplicateNeedCount(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNeedAfterDropGlobal(t *testing.T) {
|
||||
db := newLowlevelMemory(t)
|
||||
defer db.Close()
|
||||
|
||||
folder := "test"
|
||||
testFs := fs.NewFilesystem(fs.FilesystemTypeFake, "")
|
||||
|
||||
fs := newFileSet(t, folder, testFs, db)
|
||||
|
||||
// Initial:
|
||||
// Three devices and a file "test": local has Version 1, remoteDevice0
|
||||
// Version 2 and remoteDevice2 doesn't have it.
|
||||
// All of them have "bar", just so the db knows about remoteDevice2.
|
||||
files := []protocol.FileInfo{
|
||||
{Name: "foo", Version: protocol.Vector{}.Update(myID), Sequence: 1},
|
||||
{Name: "bar", Version: protocol.Vector{}.Update(myID), Sequence: 2},
|
||||
}
|
||||
fs.Update(protocol.LocalDeviceID, files)
|
||||
files[0].Version = files[0].Version.Update(myID)
|
||||
fs.Update(remoteDevice0, files)
|
||||
fs.Update(remoteDevice1, files[1:])
|
||||
|
||||
// remoteDevice1 needs one file: test
|
||||
snap := fs.Snapshot()
|
||||
c := snap.NeedSize(remoteDevice1)
|
||||
if c.Files != 1 {
|
||||
t.Errorf("Expected 1 needed files initially, got %v", c.Files)
|
||||
}
|
||||
snap.Release()
|
||||
|
||||
// Drop remoteDevice0, i.e. remove all their files from db.
|
||||
// That changes the global file, which is now what local has.
|
||||
fs.Drop(remoteDevice0)
|
||||
|
||||
// remoteDevice1 still needs test.
|
||||
snap = fs.Snapshot()
|
||||
c = snap.NeedSize(remoteDevice1)
|
||||
if c.Files != 1 {
|
||||
t.Errorf("Expected still 1 needed files, got %v", c.Files)
|
||||
}
|
||||
snap.Release()
|
||||
}
|
||||
|
||||
func numBlockLists(db *Lowlevel) (int, error) {
|
||||
it, err := db.Backend.NewPrefixIterator([]byte{KeyTypeBlockList})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user