lib/db: Initialize need meta on first dev occurrence (fixes #6668) (#6669)

This commit is contained in:
Simon Frei
2020-05-20 11:04:45 +02:00
committed by Jakob Borg
parent 9a5f7fbadf
commit 8c74177699
2 changed files with 27 additions and 2 deletions
+9 -2
View File
@@ -118,9 +118,16 @@ func (m *metadataTracker) countsPtr(dev protocol.DeviceID, flag uint32) *Counts
idx = len(m.counts.Counts)
m.counts.Counts = append(m.counts.Counts, Counts{DeviceID: dev[:], LocalFlags: flag})
m.indexes[key] = idx
if flag == needFlag {
// Need bucket must be initialized when a device first occurs in
// the metadatatracker, even if there's no change to the need
// bucket itself.
nkey := metaKey{dev, needFlag}
nidx, ok := m.indexes[nkey]
if !ok {
// Initially a new device needs everything, except deletes
m.counts.Counts[idx] = m.allNeededCounts(dev)
nidx = len(m.counts.Counts)
m.counts.Counts = append(m.counts.Counts, m.allNeededCounts(dev))
m.indexes[nkey] = nidx
}
}
return &m.counts.Counts[idx]