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:
@@ -29,7 +29,6 @@ import (
|
||||
const (
|
||||
folderID = "test"
|
||||
blockSize = 128 << 10
|
||||
dirSize = 128
|
||||
)
|
||||
|
||||
func TestBasics(t *testing.T) {
|
||||
@@ -72,11 +71,11 @@ func TestBasics(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const (
|
||||
localSize = (1+2+3)*blockSize + dirSize
|
||||
localSize = (1+2+3)*blockSize
|
||||
remoteSize = (3 + 4 + 5) * blockSize
|
||||
globalSize = (2+3+3+4+5)*blockSize + dirSize
|
||||
globalSize = (2+3+3+4+5)*blockSize
|
||||
needSizeLocal = remoteSize
|
||||
needSizeRemote = (2+3)*blockSize + dirSize
|
||||
needSizeRemote = (2+3)*blockSize
|
||||
)
|
||||
|
||||
t.Run("SchemaVersion", func(t *testing.T) {
|
||||
|
||||
@@ -111,10 +111,6 @@ func (s *folderDB) Update(device protocol.DeviceID, fs []protocol.FileInfo, opti
|
||||
f.BlocksHash = nil
|
||||
}
|
||||
|
||||
if f.Type == protocol.FileInfoTypeDirectory {
|
||||
f.Size = 128 // synthetic directory size
|
||||
}
|
||||
|
||||
// Insert the file.
|
||||
//
|
||||
// If it is a remote file, set remote_sequence otherwise leave it at
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
-- Copyright (C) 2026 The Syncthing Authors.
|
||||
--
|
||||
-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
-- You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
-- All non-file entries should have size zero.
|
||||
-- Directories were previously stored with a "synthetic" size of 128.
|
||||
UPDATE files
|
||||
SET size = 0
|
||||
WHERE type != 0
|
||||
;
|
||||
@@ -106,6 +106,10 @@ func (i indirectFI) FileInfo() (protocol.FileInfo, error) {
|
||||
fi.Blocks = bl.Blocks
|
||||
}
|
||||
fi.Name = osutil.NativeFilename(fi.Name)
|
||||
// Undo earlier behaviour of setting a synthetic size on dirs.
|
||||
if fi.Type != protocol.FileInfoTypeFile && fi.Size > 0 {
|
||||
fi.Size = 0
|
||||
}
|
||||
return protocol.FileInfoFromDB(&fi), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user