chore: forget deleted files older than six months (fixes #6284) (#10023)

This reduces the number of file entries we carry in the database,
sometimes significantly. The downside is that if a file is deleted while
a device is offline, and that device comes back more than the cutoff
interval (six months) later, those files will get resurrected at some
point.
This commit is contained in:
Jakob Borg
2025-04-02 05:58:59 -07:00
committed by GitHub
parent 0bcc31d058
commit 86cbc2486f
2 changed files with 30 additions and 0 deletions

View File

@@ -251,6 +251,11 @@ func TryMigrateDatabase() error {
return err
}
_ = snap.WithHaveSequence(0, func(fi protocol.FileInfo) bool {
if fi.Deleted && time.Since(fi.ModTime()) > sqlite.MaxDeletedFileAge {
// Skip deleted files that match the garbage collection
// criteria in the database
return true
}
fis <- fi
return true
})