move some logging around
This commit is contained in:
parent
15bd040deb
commit
77e4f01a49
|
@ -126,21 +126,14 @@ func walk_dir(dir string, f *filter.Filter) (files Files) {
|
|||
name := d.Name()
|
||||
info, _ := d.Info()
|
||||
if f.Match(info) {
|
||||
log.Debugf("found matching file: %s %s", name, info.ModTime())
|
||||
i, err := os.Stat(p)
|
||||
if err != nil {
|
||||
log.Debugf("error in file stat: %s", err)
|
||||
return nil
|
||||
}
|
||||
files = append(files, DiskFile{
|
||||
path: p,
|
||||
name: name,
|
||||
filesize: i.Size(),
|
||||
modified: i.ModTime(),
|
||||
isdir: i.IsDir(),
|
||||
filesize: info.Size(),
|
||||
modified: info.ModTime(),
|
||||
isdir: info.IsDir(),
|
||||
mode: info.Mode(),
|
||||
})
|
||||
} else {
|
||||
log.Debugf("ignoring file %s (%s)", name, info.ModTime())
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
@ -171,7 +164,6 @@ func read_dir(dir string, f *filter.Filter) (files Files) {
|
|||
path := filepath.Dir(filepath.Join(dir, name))
|
||||
|
||||
if f.Match(info) {
|
||||
log.Debugf("found matching file: %s %s", name, info.ModTime())
|
||||
files = append(files, DiskFile{
|
||||
name: name,
|
||||
path: filepath.Join(path, name),
|
||||
|
@ -179,8 +171,6 @@ func read_dir(dir string, f *filter.Filter) (files Files) {
|
|||
filesize: info.Size(),
|
||||
isdir: info.IsDir(),
|
||||
})
|
||||
} else {
|
||||
log.Debugf("ignoring file %s (%s)", name, info.ModTime())
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
@ -96,7 +96,6 @@ func FindTrash(trashdir, ogdir string, f *filter.Filter) (files Files, outerr er
|
|||
}
|
||||
|
||||
if f.Match(info) {
|
||||
log.Debugf("%s: deleted on %s", filename, date.Format(trash_info_date_fmt))
|
||||
files = append(files, TrashInfo{
|
||||
name: filename,
|
||||
path: trashedpath,
|
||||
|
@ -106,8 +105,6 @@ func FindTrash(trashdir, ogdir string, f *filter.Filter) (files Files, outerr er
|
|||
isdir: info.IsDir(),
|
||||
filesize: info.Size(),
|
||||
})
|
||||
} else {
|
||||
log.Debugf("(ignored) %s: deleted on %s", filename, date.Format(trash_info_date_fmt))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,62 +59,76 @@ func (f *Filter) Match(info fs.FileInfo) bool {
|
|||
// on or before/after, not both
|
||||
if !f.on.IsZero() {
|
||||
if !same_day(f.on, modified) {
|
||||
log.Debugf("%s: %s isn't on %s, bye!", filename, modified, f.on)
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if !f.after.IsZero() && f.after.After(modified) {
|
||||
log.Debugf("%s: %s isn't after %s, bye!", filename, modified, f.after)
|
||||
return false
|
||||
}
|
||||
if !f.before.IsZero() && f.before.Before(modified) {
|
||||
log.Debugf("%s: %s isn't before %s, bye!", filename, modified, f.before)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if f.has_regex() && !f.matcher.MatchString(filename) {
|
||||
log.Debugf("%s doesn't match `%s`, bye!", filename, f.matcher.String())
|
||||
return false
|
||||
}
|
||||
|
||||
if f.glob != "" {
|
||||
if match, err := filepath.Match(f.glob, filename); err != nil || !match {
|
||||
log.Debugf("%s doesn't match `%s`, bye!", filename, f.glob)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if f.has_unregex() && f.unmatcher.MatchString(filename) {
|
||||
log.Debugf("%s matches `%s`, bye!", filename, f.unmatcher.String())
|
||||
return false
|
||||
}
|
||||
|
||||
if f.unglob != "" {
|
||||
if match, err := filepath.Match(f.unglob, filename); err != nil || match {
|
||||
log.Debugf("%s matches `%s`, bye!", filename, f.unglob)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if len(f.filenames) > 0 && !slices.Contains(f.filenames, filename) {
|
||||
log.Debugf("%s isn't in %v, bye!", filename, f.filenames)
|
||||
return false
|
||||
}
|
||||
|
||||
if f.filesonly && isdir {
|
||||
log.Debugf("%s is dir, bye!", filename)
|
||||
return false
|
||||
}
|
||||
|
||||
if f.dirsonly && !isdir {
|
||||
log.Debugf("%s is file, bye!", filename)
|
||||
return false
|
||||
}
|
||||
|
||||
if f.ignorehidden && strings.HasPrefix(filename, ".") {
|
||||
log.Debugf("%s is hidden, bye!", filename)
|
||||
return false
|
||||
}
|
||||
|
||||
if f.maxsize != 0 && f.maxsize < size {
|
||||
log.Debugf("%s is larger than %d, bye!", filename, f.maxsize)
|
||||
return false
|
||||
}
|
||||
|
||||
if f.minsize != 0 && f.minsize > size {
|
||||
log.Debugf("%s is smaller than %d, bye!", filename, f.minsize)
|
||||
return false
|
||||
}
|
||||
|
||||
// okay it was good
|
||||
log.Debugf("%s modified:'%s' dir:'%T' mode:'%s' was a good one!", filename, modified, isdir, mode)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue