summaryrefslogtreecommitdiff
path: root/internal/config/settings.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/settings.go')
-rw-r--r--internal/config/settings.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/internal/config/settings.go b/internal/config/settings.go
index 97355a5..efc935b 100644
--- a/internal/config/settings.go
+++ b/internal/config/settings.go
@@ -34,6 +34,7 @@ type Settings struct {
MaxDepth *int
MinAge *time.Duration
MaxRead *int64
+ MaxSize *int64
Busy *[]string
OnConflict *Conflict
}
@@ -46,6 +47,7 @@ type Resolved struct {
MaxDepth int // 0 means unlimited
MinAge time.Duration
MaxRead int64
+ MaxSize int64 // 0 means unlimited
Busy []string
OnConflict Conflict
}
@@ -83,6 +85,9 @@ func (s Settings) Over(base Resolved) Resolved {
if s.MaxRead != nil {
r.MaxRead = *s.MaxRead
}
+ if s.MaxSize != nil {
+ r.MaxSize = *s.MaxSize
+ }
if s.Busy != nil {
r.Busy = *s.Busy
}
@@ -92,7 +97,7 @@ func (s Settings) Over(base Resolved) Resolved {
return r
}
-var settingNames = []string{"case", "fold", "recursive", "max-depth", "min-age", "max-read", "busy", "on-conflict"}
+var settingNames = []string{"case", "fold", "recursive", "max-depth", "min-age", "max-read", "max-size", "busy", "on-conflict"}
// ruleSettings are the settings a rule may override.
var ruleSettings = map[string]bool{"case": true, "fold": true, "on-conflict": true}
@@ -106,6 +111,7 @@ var settingHint = map[string]string{
"max-depth": "a number, like (max-depth 3)",
"min-age": "a duration, like (min-age 2m)",
"max-read": "a size, like (max-read 50M)",
+ "max-size": "a size, like (max-size 1G)",
"on-conflict": "(on-conflict suffix), skip or overwrite",
}
@@ -183,6 +189,13 @@ func (s *Settings) parse(n *sexp.Node, d *diags, seen map[string]*sexp.Node) {
return
}
s.MaxRead = &size
+ case "max-size":
+ size, err := ParseSize(v)
+ if err != nil {
+ d.at(at, "max-size: %v", err)
+ return
+ }
+ s.MaxSize = &size
case "on-conflict":
c, ok := map[string]Conflict{"suffix": ConflictSuffix, "skip": ConflictSkip, "overwrite": ConflictOverwrite}[v]
if !ok {