lib/db: Keep folder meta data persistently in db (fixes #4400)
This keeps the data we need about sequence numbers and object counts persistently in the database. The sizeTracker is expanded into a metadataTracker than handled multiple folders, and the Counts struct is made protobuf serializable. It gains a Sequence field to assist in tracking that as well, and a collection of Counts become a CountsSet (for serialization purposes). The initial database scan is also a consistency check of the global entries. This shouldn't strictly be necessary. Nonetheless I added a created timestamp to the metadata and set a variable to compare against that. When the time since the metadata creation is old enough, we drop the metadata and rebuild from scratch like we used to, while also consistency checking. A new environment variable STCHECKDBEVERY can override this interval, and for example be set to zero to force the check immediately. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4547 LGTM: imsodin
This commit is contained in:
committed by
Audrius Butkevicius
parent
8c91ced784
commit
d1d967f0cf
@@ -169,7 +169,7 @@ func TestGlobalSet(t *testing.T) {
|
||||
t.Errorf("Global incorrect;\n A: %v !=\n E: %v", g, expectedGlobal)
|
||||
}
|
||||
|
||||
globalFiles, globalDirectories, globalDeleted, globalBytes := 0, 0, 0, int64(0)
|
||||
globalFiles, globalDirectories, globalDeleted, globalBytes := int32(0), int32(0), int32(0), int64(0)
|
||||
for _, f := range g {
|
||||
if f.IsInvalid() {
|
||||
continue
|
||||
@@ -205,7 +205,7 @@ func TestGlobalSet(t *testing.T) {
|
||||
t.Errorf("Have incorrect;\n A: %v !=\n E: %v", h, localTot)
|
||||
}
|
||||
|
||||
haveFiles, haveDirectories, haveDeleted, haveBytes := 0, 0, 0, int64(0)
|
||||
haveFiles, haveDirectories, haveDeleted, haveBytes := int32(0), int32(0), int32(0), int64(0)
|
||||
for _, f := range h {
|
||||
if f.IsInvalid() {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user