mirror of
https://github.com/syncthing/syncthing.git
synced 2026-10-28 22:18:31 -04:00
fix(sqlite): avoid early garbage collection of deleted recv-enc files (#10916)
Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
1 parent
529ced6c6b
commit
84329b277f
1 file changed
+6
-1
@@ -218,6 +218,10 @@ func garbageCollectOldDeletedLocked(ctx context.Context, fdb *folderDB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Receive-encrypted files always have the timestamp below. We cannot
|
||||
// use this to conclude a deleted file is safe for garbage collection.
|
||||
recvEncModified := 1234567890 * time.Second
|
||||
|
||||
// Remove deleted files that are marked as not needed (we have processed
|
||||
// them) and they were deleted more than MaxDeletedFileAge ago.
|
||||
// Keep the local high-water mark reachable by the index sender.
|
||||
@@ -225,12 +229,13 @@ func garbageCollectOldDeletedLocked(ctx context.Context, fdb *folderDB) error {
|
||||
res, err := fdb.stmt(`
|
||||
DELETE FROM files
|
||||
WHERE deleted
|
||||
AND modified != ?
|
||||
AND modified < ?
|
||||
AND local_flags & {{.FlagLocalNeeded}} == 0
|
||||
AND sequence NOT IN (
|
||||
SELECT sequence FROM indexids WHERE device_idx = {{.LocalDeviceIdx}}
|
||||
)
|
||||
`).Exec(time.Now().Add(-fdb.deleteRetention).UnixNano())
|
||||
`).Exec(recvEncModified, time.Now().Add(-fdb.deleteRetention).UnixNano())
|
||||
if err != nil {
|
||||
return wrap(err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user