Skip to content

Commit 280b9ab

Browse files
committed
Make faster by only updating screen every 250ms
1 parent c8e8d00 commit 280b9ab

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

fssize.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ func (fssize *FSSize) walkDir(path string, d fs.DirEntry, walkDirFn fs.WalkDirFu
217217
fssize.folders = append(fssize.folders, File{path: path, sizeBytes: dirSize})
218218
fssize.SortFiles(&fssize.folders)
219219

220-
if fssize.app != nil && fssize.currentTab == Folders {
220+
/*if fssize.app != nil && fssize.currentTab == Folders {
221221
fssize.app.QueueUpdateDraw(func() {})
222-
}
222+
}*/
223223
}
224224
} else {
225225
fssize.folders = append(fssize.folders, File{path: path, sizeBytes: dirSize})
@@ -344,9 +344,9 @@ func (fssize *FSSize) AccumulateFilesAndFolders() error {
344344
fssize.files = append(fssize.files, File{path: path, sizeBytes: info.Size()})
345345
fssize.SortFiles(&fssize.files)
346346

347-
if fssize.app != nil && fssize.currentTab == Files {
347+
/*if fssize.app != nil && fssize.currentTab == Files {
348348
fssize.app.QueueUpdateDraw(func() {})
349-
}
349+
}*/
350350
return nil
351351
}
352352

main.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"path/filepath"
99
"strings"
10+
"time"
1011

1112
"github.com/gdamore/tcell/v2"
1213
"github.com/rivo/tview"
@@ -15,7 +16,7 @@ import (
1516
)
1617

1718
const programName = "fssize"
18-
const version = "v0.0.1"
19+
const version = "v0.0.2"
1920

2021
func printError(str string) {
2122
os.Stderr.WriteString("\x1b[0;31m" + programName + ": " + str + "\x1b[0m\n")
@@ -153,6 +154,14 @@ This outputs the estimated kibibyte (KiB) size of all packages`)
153154
fssize.AccumulatePackages()
154155
go fssize.AccumulateFilesAndFolders()
155156

157+
fssize.accumulating = true // Just to make sure the below goroutine doesn't quit early
158+
go func() {
159+
for fssize.accumulating {
160+
time.Sleep(250 * time.Millisecond)
161+
app.QueueUpdateDraw(func() {})
162+
}
163+
}()
164+
156165
if err := app.SetRoot(fssize, true).Run(); err != nil {
157166
log.Fatal(err)
158167
}

0 commit comments

Comments
 (0)