Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

ncdu: fix crash when re-entering changed directory after rescan

Nick Craig-Wood53868ef4e147
diff --git a/cmd/ncdu/ncdu.go b/cmd/ncdu/ncdu.go
index 0482a71c0..cde48d972 100644
--- a/cmd/ncdu/ncdu.go
+++ b/cmd/ncdu/ncdu.go
@@ -386,6 +386,12 @@ func (u *UI) Draw() {
}
showEmptyDir := u.hasEmptyDir()
dirPos := u.dirPosMap[u.path]
+ // Check to see if a rescan has invalidated the position
+ if dirPos.offset >= len(u.sortPerm) {
+ delete(u.dirPosMap, u.path)
+ dirPos.offset = 0
+ dirPos.entry = 0
+ }
for i, j := range u.sortPerm[dirPos.offset:] {
entry := u.entries[j]
n := i + dirPos.offset