@@ -16,15 +16,17 @@ import (
1616
1717// OrphanScanSettings represents orphan scan settings for an instance.
1818type OrphanScanSettings struct {
19- ID int64 `json:"id"`
20- InstanceID int `json:"instanceId"`
21- Enabled bool `json:"enabled"`
22- GracePeriodMinutes int `json:"gracePeriodMinutes"`
23- IgnorePaths []string `json:"ignorePaths"`
24- ScanIntervalHours int `json:"scanIntervalHours"`
25- MaxFilesPerRun int `json:"maxFilesPerRun"`
26- CreatedAt time.Time `json:"createdAt"`
27- UpdatedAt time.Time `json:"updatedAt"`
19+ ID int64 `json:"id"`
20+ InstanceID int `json:"instanceId"`
21+ Enabled bool `json:"enabled"`
22+ GracePeriodMinutes int `json:"gracePeriodMinutes"`
23+ IgnorePaths []string `json:"ignorePaths"`
24+ ScanIntervalHours int `json:"scanIntervalHours"`
25+ MaxFilesPerRun int `json:"maxFilesPerRun"`
26+ AutoCleanupEnabled bool `json:"autoCleanupEnabled"`
27+ AutoCleanupMaxFiles int `json:"autoCleanupMaxFiles"`
28+ CreatedAt time.Time `json:"createdAt"`
29+ UpdatedAt time.Time `json:"updatedAt"`
2830}
2931
3032// OrphanScanRun represents an orphan scan run.
@@ -70,7 +72,8 @@ func NewOrphanScanStore(db dbinterface.Querier) *OrphanScanStore {
7072func (s * OrphanScanStore ) GetSettings (ctx context.Context , instanceID int ) (* OrphanScanSettings , error ) {
7173 row := s .db .QueryRowContext (ctx , `
7274 SELECT id, instance_id, enabled, grace_period_minutes, ignore_paths,
73- scan_interval_hours, max_files_per_run, created_at, updated_at
75+ scan_interval_hours, max_files_per_run, auto_cleanup_enabled,
76+ auto_cleanup_max_files, created_at, updated_at
7477 FROM orphan_scan_settings
7578 WHERE instance_id = ?
7679 ` , instanceID )
@@ -86,6 +89,8 @@ func (s *OrphanScanStore) GetSettings(ctx context.Context, instanceID int) (*Orp
8689 & ignorePathsJSON ,
8790 & settings .ScanIntervalHours ,
8891 & settings .MaxFilesPerRun ,
92+ & settings .AutoCleanupEnabled ,
93+ & settings .AutoCleanupMaxFiles ,
8994 & settings .CreatedAt ,
9095 & settings .UpdatedAt ,
9196 )
@@ -121,16 +126,20 @@ func (s *OrphanScanStore) UpsertSettings(ctx context.Context, settings *OrphanSc
121126
122127 _ , err = s .db .ExecContext (ctx , `
123128 INSERT INTO orphan_scan_settings
124- (instance_id, enabled, grace_period_minutes, ignore_paths, scan_interval_hours, max_files_per_run)
125- VALUES (?, ?, ?, ?, ?, ?)
129+ (instance_id, enabled, grace_period_minutes, ignore_paths, scan_interval_hours,
130+ max_files_per_run, auto_cleanup_enabled, auto_cleanup_max_files)
131+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
126132 ON CONFLICT(instance_id) DO UPDATE SET
127133 enabled = excluded.enabled,
128134 grace_period_minutes = excluded.grace_period_minutes,
129135 ignore_paths = excluded.ignore_paths,
130136 scan_interval_hours = excluded.scan_interval_hours,
131- max_files_per_run = excluded.max_files_per_run
137+ max_files_per_run = excluded.max_files_per_run,
138+ auto_cleanup_enabled = excluded.auto_cleanup_enabled,
139+ auto_cleanup_max_files = excluded.auto_cleanup_max_files
132140 ` , settings .InstanceID , boolToInt (settings .Enabled ), settings .GracePeriodMinutes ,
133- string (ignorePathsJSON ), settings .ScanIntervalHours , settings .MaxFilesPerRun )
141+ string (ignorePathsJSON ), settings .ScanIntervalHours , settings .MaxFilesPerRun ,
142+ boolToInt (settings .AutoCleanupEnabled ), settings .AutoCleanupMaxFiles )
134143 if err != nil {
135144 return nil , err
136145 }
0 commit comments