fix: increase default delete retention to 15 months (#10252)

365 + 90 days = 10920h.

Also, actually enforce the minimum interval of 24h.
This commit is contained in:
Jakob Borg
2025-08-14 08:15:53 +02:00
committed by GitHub
parent 370bbb8f26
commit 7a76685d7e
4 changed files with 16 additions and 11 deletions

View File

@@ -155,7 +155,7 @@ type serveCmd struct {
Audit bool `help:"Write events to audit file" env:"STAUDIT"`
AuditFile string `name:"auditfile" help:"Specify audit file (use \"-\" for stdout, \"--\" for stderr)" placeholder:"PATH" env:"STAUDITFILE"`
DBMaintenanceInterval time.Duration `help:"Database maintenance interval" default:"8h" env:"STDBMAINTENANCEINTERVAL"`
DBDeleteRetentionInterval time.Duration `help:"Database deleted item retention interval" default:"4320h" env:"STDBDELETERETENTIONINTERVAL"`
DBDeleteRetentionInterval time.Duration `help:"Database deleted item retention interval" default:"10920h" env:"STDBDELETERETENTIONINTERVAL"`
GUIAddress string `name:"gui-address" help:"Override GUI address (e.g. \"http://192.0.2.42:8443\")" placeholder:"URL" env:"STGUIADDRESS"`
GUIAPIKey string `name:"gui-apikey" help:"Override GUI API key" placeholder:"API-KEY" env:"STGUIAPIKEY"`
LogFile string `name:"log-file" aliases:"logfile" help:"Log file name (see below)" default:"${logFile}" placeholder:"PATH" env:"STLOGFILE"`

View File

@@ -17,14 +17,17 @@ import (
"github.com/syncthing/syncthing/internal/slogutil"
)
const maxDBConns = 16
const (
maxDBConns = 16
minDeleteRetention = 24 * time.Hour
)
type DB struct {
*baseDB
pathBase string
deleteRetention time.Duration
*baseDB
folderDBsMut sync.RWMutex
folderDBs map[string]*folderDB
folderDBOpener func(folder, path string, deleteRetention time.Duration) (*folderDB, error)
@@ -36,7 +39,11 @@ type Option func(*DB)
func WithDeleteRetention(d time.Duration) Option {
return func(s *DB) {
s.deleteRetention = d
if d <= 0 {
s.deleteRetention = 0
} else {
s.deleteRetention = max(d, minDeleteRetention)
}
}
}

View File

@@ -19,10 +19,8 @@ import (
)
const (
internalMetaPrefix = "dbsvc"
lastMaintKey = "lastMaint"
defaultDeleteRetention = 180 * 24 * time.Hour
minDeleteRetention = 24 * time.Hour
internalMetaPrefix = "dbsvc"
lastMaintKey = "lastMaint"
)
func (s *DB) Service(maintenanceInterval time.Duration) suture.Service {

View File

@@ -15,8 +15,8 @@
line options have been removed and will be ignored if given.
- Deleted items are no longer kept forever in the database, instead they are
forgotten after six months. If your use case require deletes to take
effect after more than a six month delay, set the
forgotten after fifteen months. If your use case require deletes to take
effect after more than a fifteen month delay, set the
`--db-delete-retention-interval` command line option or corresponding
environment variable to zero, or a longer time interval of your choosing.