diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 7043b7d2c..20ad09b9f 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -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"` diff --git a/internal/db/sqlite/db_open.go b/internal/db/sqlite/db_open.go index 927135dc4..2a601a42e 100644 --- a/internal/db/sqlite/db_open.go +++ b/internal/db/sqlite/db_open.go @@ -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) + } } } diff --git a/internal/db/sqlite/db_service.go b/internal/db/sqlite/db_service.go index de2e68ddf..1a5b68d16 100644 --- a/internal/db/sqlite/db_service.go +++ b/internal/db/sqlite/db_service.go @@ -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 { diff --git a/relnotes/v2.0.md b/relnotes/v2.0.md index 24c192b99..67be67605 100644 --- a/relnotes/v2.0.md +++ b/relnotes/v2.0.md @@ -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.