chore: stop treating dirs as having size 128 (#10750)

Resp. directories for the database, and both dirs and symlinks for
`FileInfo.FileSize`. Instead handle it in the UI progress percentage. We
even already have special cases there for deletions, might as well
handle directories just like any other zero-sized needed item there.

This went through the very thorough testing of running it on my laptop,
the migration was applied and it seemed to be working fine after.

---------

Signed-off-by: Simon Frei <freisim93@gmail.com>
This commit is contained in:
Simon Frei
2026-06-22 20:32:03 +02:00
committed by GitHub
parent 5313c75eba
commit c9236b1adc
12 changed files with 44 additions and 41 deletions
+4 -5
View File
@@ -163,12 +163,11 @@ func TestRecvOnlyRevertNeeds(t *testing.T) {
// We now have a newer file than the rest of the cluster. Global state should reflect this.
size = mustV(m.GlobalSize("ro"))
const sizeOfDir = 128
if size.Files != 1 || size.Bytes != sizeOfDir+int64(len(oldData)) {
if size.Files != 1 || size.Bytes != int64(len(oldData)) {
t.Fatalf("Global: expected no change due to the new file: %+v", size)
}
size = mustV(m.LocalSize("ro", protocol.LocalDeviceID))
if size.Files != 1 || size.Bytes != sizeOfDir+int64(len(newData)) {
if size.Files != 1 || size.Bytes != int64(len(newData)) {
t.Fatalf("Local: expected the new file to be reflected: %+v", size)
}
size = mustV(m.NeedSize("ro", protocol.LocalDeviceID))
@@ -185,11 +184,11 @@ func TestRecvOnlyRevertNeeds(t *testing.T) {
m.Revert("ro")
size = mustV(m.GlobalSize("ro"))
if size.Files != 1 || size.Bytes != sizeOfDir+int64(len(oldData)) {
if size.Files != 1 || size.Bytes != int64(len(oldData)) {
t.Fatalf("Global: expected the global size to revert: %+v", size)
}
size = mustV(m.LocalSize("ro", protocol.LocalDeviceID))
if size.Files != 1 || size.Bytes != sizeOfDir+int64(len(newData)) {
if size.Files != 1 || size.Bytes != int64(len(newData)) {
t.Fatalf("Local: expected the local size to remain: %+v", size)
}
size = mustV(m.NeedSize("ro", protocol.LocalDeviceID))
+4 -2
View File
@@ -1787,10 +1787,12 @@ func TestGlobalDirectoryTree(t *testing.T) {
b := func(isfile bool, path ...string) protocol.FileInfo {
typ := protocol.FileInfoTypeDirectory
var blocks []protocol.BlockInfo
var size int64
if isfile {
typ = protocol.FileInfoTypeFile
blocks = []protocol.BlockInfo{{Offset: 0x0, Size: 0xa, Hash: []uint8{0x2f, 0x72, 0xcc, 0x11, 0xa6, 0xfc, 0xd0, 0x27, 0x1e, 0xce, 0xf8, 0xc6, 0x10, 0x56, 0xee, 0x1e, 0xb1, 0x24, 0x3b, 0xe3, 0x80, 0x5b, 0xf9, 0xa9, 0xdf, 0x98, 0xf9, 0x2f, 0x76, 0x36, 0xb0, 0x5c}}}
size = 0xa
}
seq++
return protocol.FileInfo{
@@ -1798,7 +1800,7 @@ func TestGlobalDirectoryTree(t *testing.T) {
Type: typ,
ModifiedS: 0x666,
Blocks: blocks,
Size: 0xa,
Size: size,
Sequence: seq,
}
}
@@ -1814,7 +1816,7 @@ func TestGlobalDirectoryTree(t *testing.T) {
return &TreeEntry{
Name: name,
ModTime: time.Unix(0x666, 0),
Size: 128,
Size: 0,
Type: protocol.FileInfoTypeDirectory.String(),
Children: entries,
}