filesize of -1 for directories for proper sorting

maybe actually count directory size someday
but then a new column would have to be added
This commit is contained in:
Lilian Jónsdóttir 2024-07-15 15:06:53 -07:00
parent e0ffb8502c
commit af2af0c587
2 changed files with 12 additions and 2 deletions

View file

@ -23,8 +23,13 @@ type DiskFile struct {
func (f DiskFile) Name() string { return f.name }
func (f DiskFile) Path() string { return filepath.Join(f.path, f.name) }
func (f DiskFile) Date() time.Time { return f.modified }
func (f DiskFile) Filesize() int64 { return f.filesize }
func (f DiskFile) IsDir() bool { return f.isdir }
func (f DiskFile) Filesize() int64 {
if f.isdir {
return -1
}
return f.filesize
}
func NewDisk(path string) (DiskFile, error) {
info, err := os.Stat(path)

View file

@ -46,8 +46,13 @@ func (t TrashInfo) TrashPath() string { return t.path }
func (t TrashInfo) Path() string { return t.ogpath }
func (t TrashInfo) TrashInfo() string { return t.trashinfo }
func (t TrashInfo) Date() time.Time { return t.trashed }
func (t TrashInfo) Filesize() int64 { return t.filesize }
func (t TrashInfo) IsDir() bool { return t.isdir }
func (t TrashInfo) Filesize() int64 {
if t.isdir {
return -1
}
return t.filesize
}
func FindTrash(trashdir, ogdir string, f *filter.Filter) (files Files, outerr error) {
outerr = filepath.WalkDir(trashdir, func(path string, d fs.DirEntry, err error) error {