Compare commits
2 Commits
4248994b75
...
51c6ca56ac
Author | SHA1 | Date | |
---|---|---|---|
|
51c6ca56ac | ||
|
8eb4c0d173 |
13
dir_entry.go
13
dir_entry.go
@ -141,13 +141,6 @@ func (e *DirectoryEntry) SetRemovalMark(mark bool) {
|
||||
for _, entry := range e.Entries() {
|
||||
entry.SetRemovalMark(mark)
|
||||
}
|
||||
|
||||
if e.Parent() != nil {
|
||||
pentries := e.Parent().Entries()
|
||||
sort.Slice(pentries, func(i, j int) bool {
|
||||
return pentries[i].SizeModified() < pentries[j].SizeModified()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (e *DirectoryEntry) RemovalMark() bool {
|
||||
@ -166,6 +159,12 @@ func (e *DirectoryEntry) modifySize(modifier uint64) {
|
||||
*e.modSize += modifier
|
||||
if e.parent != nil {
|
||||
e.parent.modifySize(modifier)
|
||||
|
||||
// recalculate order of parent entries
|
||||
pentries := e.Parent().Entries()
|
||||
sort.Slice(pentries, func(i, j int) bool {
|
||||
return pentries[i].SizeModified() < pentries[j].SizeModified()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -117,6 +118,12 @@ func (e *FileEntry) SetRemovalMark(mark bool) {
|
||||
} else {
|
||||
e.modifySize(*e.size)
|
||||
}
|
||||
|
||||
// recalculate order of parent entries
|
||||
pentries := e.Parent().Entries()
|
||||
sort.Slice(pentries, func(i, j int) bool {
|
||||
return pentries[i].SizeModified() < pentries[j].SizeModified()
|
||||
})
|
||||
}
|
||||
|
||||
func (e *FileEntry) RemovalMark() bool {
|
||||
|
8
go.mod
8
go.mod
@ -1,15 +1,11 @@
|
||||
module git.tordarus.net/Tordarus/diskspace
|
||||
module git.milar.in/milarin/diskspace
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/fatih/color v1.13.0
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
|
||||
)
|
||||
require github.com/fatih/color v1.13.0
|
||||
|
||||
require (
|
||||
github.com/mattn/go-colorable v0.1.9 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
|
||||
)
|
||||
|
5
go.sum
5
go.sum
@ -5,12 +5,7 @@ github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
|
6
main.go
6
main.go
@ -26,6 +26,12 @@ var (
|
||||
IconTheme = flag.String("i", "unicode", "icon theme (currently supported: default, unicode, nerd)")
|
||||
)
|
||||
|
||||
// FIXME sometimes sorting not applied after removing items
|
||||
// TODO pwd command showing Current entry path and Root entry path in filesystem
|
||||
// TODO arrow up -> last command (`stty -raw` necessary?). even better: rlwrap impl (see tsoding noq)
|
||||
// TODO config file with preferred icon theme or read best icon theme from terminfo somehow
|
||||
// TODO on exit: show deleted files in recursive tree (only deleted files and their parent directories)
|
||||
// TODO autocomplete on TAB (see arrow up issue: raw necessary?)
|
||||
func main() {
|
||||
flag.Parse()
|
||||
rootPath := flag.Arg(0)
|
||||
|
Loading…
Reference in New Issue
Block a user