@@ -21,21 +21,22 @@ import (
2121const (
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
2930type 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+
7789func (u * Unpackerr ) logFolders () {
7890 if epath , count := "" , len (u .Folders ); count == 1 {
7991 folder := u .Folders [0 ]
0 commit comments