add original-path flag for list/restore/clean files in trash

This commit is contained in:
Lilian Jónsdóttir 2024-06-18 17:02:49 -07:00
parent dddc6f6d33
commit 4d929160d1
2 changed files with 27 additions and 14 deletions

View file

@ -77,7 +77,7 @@ func (is Infos) Show(width int) {
fmt.Println(is.Table(width))
}
func FindFiles(trashdir string, f *filter.Filter) (files Infos, outerr error) {
func FindFiles(trashdir, ogdir string, f *filter.Filter) (files Infos, outerr error) {
outerr = filepath.WalkDir(trashdir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
log.Debugf("what happened?? what is %s?", err)
@ -107,6 +107,10 @@ func FindFiles(trashdir string, f *filter.Filter) (files Infos, outerr error) {
return err
}
if ogdir != "" && filepath.Dir(basepath) != ogdir {
return nil
}
if f.Match(filename, date) {
log.Debugf("%s: deleted on %s", filename, date.Format(trash_info_date_fmt))
files = append(files, Info{