mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-04 23:55:22 +00:00
parent
5fb3992275
commit
4881a6336f
lib/db
@ -314,9 +314,13 @@ func (m *metadataTracker) resetAll(dev protocol.DeviceID) {
|
||||
m.dirty = true
|
||||
for i, c := range m.counts.Counts {
|
||||
if bytes.Equal(c.DeviceID, dev[:]) {
|
||||
m.counts.Counts[i] = Counts{
|
||||
DeviceID: c.DeviceID,
|
||||
LocalFlags: c.LocalFlags,
|
||||
if c.LocalFlags != needFlag {
|
||||
m.counts.Counts[i] = Counts{
|
||||
DeviceID: c.DeviceID,
|
||||
LocalFlags: c.LocalFlags,
|
||||
}
|
||||
} else {
|
||||
m.counts.Counts[i] = m.allNeededCounts(dev)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1671,6 +1671,32 @@ func TestNeedRemoteOnly(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/syncthing/syncthing/issues/6784
|
||||
func TestNeedRemoteAfterReset(t *testing.T) {
|
||||
ldb := db.NewLowlevel(backend.OpenMemory())
|
||||
defer ldb.Close()
|
||||
|
||||
s := db.NewFileSet("test", fs.NewFilesystem(fs.FilesystemTypeFake, ""), ldb)
|
||||
|
||||
files := fileList{
|
||||
protocol.FileInfo{Name: "b", Version: protocol.Vector{Counters: []protocol.Counter{{ID: myID, Value: 1001}}}, Blocks: genBlocks(2)},
|
||||
}
|
||||
s.Update(protocol.LocalDeviceID, files)
|
||||
s.Update(remoteDevice0, files)
|
||||
|
||||
need := needSize(s, remoteDevice0)
|
||||
if !need.Equal(db.Counts{}) {
|
||||
t.Error("Expected nothing needed, got", need)
|
||||
}
|
||||
|
||||
s.Drop(remoteDevice0)
|
||||
|
||||
need = needSize(s, remoteDevice0)
|
||||
if exp := (db.Counts{Files: 1}); !need.Equal(exp) {
|
||||
t.Errorf("Expected %v, got %v", exp, need)
|
||||
}
|
||||
}
|
||||
|
||||
func replace(fs *db.FileSet, device protocol.DeviceID, files []protocol.FileInfo) {
|
||||
fs.Drop(device)
|
||||
fs.Update(device, files)
|
||||
|
Loading…
Reference in New Issue
Block a user