diff options
Diffstat (limited to 'internal/scan/scan.go')
| -rw-r--r-- | internal/scan/scan.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/scan/scan.go b/internal/scan/scan.go index e87b741..7fe9e92 100644 --- a/internal/scan/scan.go +++ b/internal/scan/scan.go @@ -36,6 +36,7 @@ const ( Symlink // a symbolic link (never followed) NotRegular // fifo, socket, device Unreadable // a directory that could not be read + TooBig // larger than MaxSize ) // String names a Reason the way it should read in a report. @@ -53,6 +54,8 @@ func (r Reason) String() string { return "not a regular file" case Unreadable: return "unreadable" + case TooBig: + return "too big" default: return fmt.Sprintf("Reason(%d)", int(r)) } @@ -72,6 +75,7 @@ type Options struct { Exclude []string // absolute directories never entered Busy []string // suffixes, e.g. ".part" MinAge time.Duration + MaxSize int64 // bytes; 0: no limit Now time.Time } @@ -209,6 +213,10 @@ func (w *walker) walk(dir, relDir string, depth int, entries []os.DirEntry) erro w.result.Skipped = append(w.result.Skipped, Skipped{Rel: rel, Reason: TooNew}) continue } + if w.opt.MaxSize > 0 && info.Size() > w.opt.MaxSize { + w.result.Skipped = append(w.result.Skipped, Skipped{Rel: rel, Reason: TooBig}) + continue + } w.result.Files = append(w.result.Files, File{ Path: path, Rel: rel, |
