fix WEEKS to recheck and assume empty modified has happy cksum

main
bel 2025-05-17 20:36:59 -06:00
parent fc66d26c10
commit f57560ebfc
1 changed files with 12 additions and 3 deletions

View File

@ -22,16 +22,25 @@ func One(ctx context.Context, p string) error {
return err
}
if threshold := 20 + time.Duration(rand.Int()%10)*24*time.Hour; time.Since(last.T) > threshold {
threshold := 20 + rand.Int()%10
if daysSince := int(time.Since(last.T).Hours()/24); daysSince > threshold {
log.Printf("asses.One(%s) // no modified check as %vd since last check", shortp, daysSince)
} else if stat, err := os.Stat(p); err != nil {
return fmt.Errorf("cannot stat %s: %w", p, err)
} else if stat.ModTime() == last.Modified {
log.Printf("asses.One(%s) // unmodified since %v", shortp, last.T)
return nil
}
} else {
log.Printf("asses.One(%s) // modified (%v) is now %v", shortp, last.Modified, stat.ModTime())
}
if err := func() error {
if len(last.Cksum) > 0 {
if last.Modified.IsZero() {
log.Printf("asses.One(%s) // assume cksum unchanged given null modified ", shortp)
return nil
}
cksum, err := Cksum(ctx, p)
if err != nil {
return err
@ -62,7 +71,7 @@ func One(ctx context.Context, p string) error {
return err
}
if err := checked(ctx, p, cksum, stat.ModTime()); err != nil {
log.Printf("failed to mark %s checked: %w", shortp, err)
log.Printf("failed to mark %s checked: %v", shortp, err)
return err
}