aboutsummaryrefslogtreecommitdiff
path: root/internal/scan/scan.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/scan/scan.go')
-rw-r--r--internal/scan/scan.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/internal/scan/scan.go b/internal/scan/scan.go
index 77cca66..bd717e0 100644
--- a/internal/scan/scan.go
+++ b/internal/scan/scan.go
@@ -229,7 +229,7 @@ func (w *walker) walk(dir, relDir string, depth int, entries []os.DirEntry) erro
w.result.Skipped = append(w.result.Skipped, Skipped{Rel: rel, Reason: Busy})
continue
}
- if w.opt.Now.Sub(info.ModTime()) < w.opt.MinAge {
+ if Age(w.opt.Now, info.ModTime()) < w.opt.MinAge {
w.result.Skipped = append(w.result.Skipped, Skipped{Rel: rel, Reason: TooNew})
continue
}
@@ -252,3 +252,13 @@ func (w *walker) isBusy(name string, names map[string]bool) bool {
}
return false
}
+
+// Age is how long ago mtime was, at now. A modification time ahead of the
+// clock (a skewed server, an archive's timestamps) counts as brand new: age
+// 0, so min-age 0 still considers the file (review cli F5).
+func Age(now, mtime time.Time) time.Duration {
+ if a := now.Sub(mtime); a > 0 {
+ return a
+ }
+ return 0
+}