mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 09:14:10 +00:00
d1d967f0cf
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
57 lines
2.0 KiB
Protocol Buffer
57 lines
2.0 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package db;
|
|
|
|
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
|
import "github.com/syncthing/syncthing/lib/protocol/bep.proto";
|
|
|
|
option (gogoproto.goproto_getters_all) = false;
|
|
option (gogoproto.sizer_all) = false;
|
|
option (gogoproto.protosizer_all) = true;
|
|
|
|
message FileVersion {
|
|
protocol.Vector version = 1 [(gogoproto.nullable) = false];
|
|
bytes device = 2;
|
|
bool invalid = 3;
|
|
}
|
|
|
|
message VersionList {
|
|
option (gogoproto.goproto_stringer) = false;
|
|
repeated FileVersion versions = 1 [(gogoproto.nullable) = false];
|
|
}
|
|
|
|
// Must be the same as FileInfo but without the blocks field
|
|
message FileInfoTruncated {
|
|
option (gogoproto.goproto_stringer) = false;
|
|
string name = 1;
|
|
protocol.FileInfoType type = 2;
|
|
int64 size = 3;
|
|
uint32 permissions = 4;
|
|
int64 modified_s = 5;
|
|
int32 modified_ns = 11;
|
|
uint64 modified_by = 12 [(gogoproto.customtype) = "github.com/syncthing/syncthing/lib/protocol.ShortID", (gogoproto.nullable) = false];
|
|
bool deleted = 6;
|
|
bool invalid = 7;
|
|
bool no_permissions = 8;
|
|
protocol.Vector version = 9 [(gogoproto.nullable) = false];
|
|
int64 sequence = 10;
|
|
string symlink_target = 17;
|
|
}
|
|
|
|
// For each folder and device we keep one of these to track the current
|
|
// counts and sequence. We also keep one for the global state of the folder.
|
|
message Counts {
|
|
int32 files = 1;
|
|
int32 directories = 2;
|
|
int32 symlinks = 3;
|
|
int32 deleted = 4;
|
|
int64 bytes = 5;
|
|
int64 sequence = 6; // zero for the global state
|
|
bytes deviceID = 17; // device ID for remote devices, or special values for local/global
|
|
}
|
|
|
|
message CountsSet {
|
|
repeated Counts counts = 1 [(gogoproto.nullable) = false];
|
|
int64 created = 2; // unix nanos
|
|
}
|