From af2af0c587413b8a7ee6fa033df7969c6321aabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Mon, 15 Jul 2024 15:06:53 -0700 Subject: [PATCH] filesize of -1 for directories for proper sorting maybe actually count directory size someday but then a new column would have to be added --- internal/files/disk.go | 7 ++++++- internal/files/trash.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/files/disk.go b/internal/files/disk.go index 70483cc..8c8f41f 100644 --- a/internal/files/disk.go +++ b/internal/files/disk.go @@ -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) diff --git a/internal/files/trash.go b/internal/files/trash.go index 87f898f..96dce56 100644 --- a/internal/files/trash.go +++ b/internal/files/trash.go @@ -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 {