Skip to content

Commit d11fc05

Browse files
committed
set default for folder delete after to 10m
1 parent 089bc9a commit d11fc05

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

pkg/unpackerr/apps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func (u *Unpackerr) validateApps() error {
134134
u.validateReadarr,
135135
u.validateSonarr,
136136
u.validateWhisparr,
137+
u.validateFolders,
137138
} {
138139
if err := validate(); err != nil {
139140
return err

pkg/unpackerr/folder.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@ import (
2121
const (
2222
defaultPollInterval = time.Second
2323
minimumPollInterval = 5 * time.Millisecond
24+
defaultFolderDelete = 10 * time.Minute
2425
)
2526

2627
// FolderConfig defines the input data for a watched folder.
2728
//
2829
//nolint:lll
2930
type FolderConfig struct {
30-
DeleteOrig bool `json:"delete_original" toml:"delete_original" xml:"delete_original" yaml:"delete_original"`
31-
DeleteFiles bool `json:"delete_files" toml:"delete_files" xml:"delete_files" yaml:"delete_files"`
32-
DisableLog bool `json:"disable_log" toml:"disable_log" xml:"disable_log" yaml:"disable_log"`
33-
MoveBack bool `json:"move_back" toml:"move_back" xml:"move_back" yaml:"move_back"`
34-
DeleteAfter cnfg.Duration `json:"delete_after" toml:"delete_after" xml:"delete_after" yaml:"delete_after"`
35-
ExtractPath string `json:"extract_path" toml:"extract_path" xml:"extract_path" yaml:"extract_path"`
36-
ExtractISOs bool `json:"extract_isos" toml:"extract_isos" xml:"extract_isos" yaml:"extract_isos"`
37-
DisableRecursion bool `json:"disableRecursion" toml:"disable_recursion" xml:"disable_recursion" yaml:"disableRecursion"`
38-
Path string `json:"path" toml:"path" xml:"path" yaml:"path"`
31+
DeleteOrig bool `json:"delete_original" toml:"delete_original" xml:"delete_original" yaml:"delete_original"`
32+
DeleteFiles bool `json:"delete_files" toml:"delete_files" xml:"delete_files" yaml:"delete_files"`
33+
DisableLog bool `json:"disable_log" toml:"disable_log" xml:"disable_log" yaml:"disable_log"`
34+
MoveBack bool `json:"move_back" toml:"move_back" xml:"move_back" yaml:"move_back"`
35+
DeleteAfter *cnfg.Duration `json:"delete_after" toml:"delete_after" xml:"delete_after" yaml:"delete_after"`
36+
ExtractPath string `json:"extract_path" toml:"extract_path" xml:"extract_path" yaml:"extract_path"`
37+
ExtractISOs bool `json:"extract_isos" toml:"extract_isos" xml:"extract_isos" yaml:"extract_isos"`
38+
DisableRecursion bool `json:"disableRecursion" toml:"disable_recursion" xml:"disable_recursion" yaml:"disableRecursion"`
39+
Path string `json:"path" toml:"path" xml:"path" yaml:"path"`
3940
}
4041

4142
// Folders holds all known (created) folders in all watch paths.
@@ -74,6 +75,17 @@ type eventData struct {
7475
op string
7576
}
7677

78+
func (u *Unpackerr) validateFolders() error {
79+
for idx := range u.Folders {
80+
if u.Folders[idx].DeleteAfter == nil {
81+
// If delete after wasn't set, then set it to 10 minutes.
82+
u.Folders[idx].DeleteAfter = &cnfg.Duration{Duration: defaultFolderDelete}
83+
}
84+
}
85+
86+
return nil
87+
}
88+
7789
func (u *Unpackerr) logFolders() {
7890
if epath, count := "", len(u.Folders); count == 1 {
7991
folder := u.Folders[0]

0 commit comments

Comments
 (0)