Conversation
Reloading a directory (e.g. after toggling `dircounts`) creates new file objects, so sizes calculated via `calcdirsize` on the old objects were lost once the reloaded directory replaced the cached one. Carry them over by path for files that are still present. Fixes gokcehan#2675 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
The fix works for #2675 but sizes are copied by path only. If a directory is deleted and created again or a file is added to it, it keeps its old size after a reload. you could copy the size only if the directory's modification time did not change. |
Compare the modification time of each directory with the previous load and drop the cached size when it differs, so a directory that was recreated or had entries added or removed gets recalculated. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@valoq thanks, good point. Pushed d8078b0: a cached size is now only copied over if the directory's modification time matches the previous load, so a recreated directory or one with entries added or removed gets recalculated. The test covers the changed mtime case too. One limit: a directory's mtime only changes when its direct entries change, so a file added deeper in the tree (say |
Fixes #2675.
set dircounts falsecallsnav.renew(), which starts an async reload of the directory because thedircountsvalue changed.calcdirsizethen runs right away and stores the sizes on the current file objects. When the reloaded directory arrives ondirChan, it replaces the cached one with fresh file objects whosedirSizeis-1, so the sizes flash on screen and then turn back into-.This adds a small
copyDirSizeshelper ondirthat carries over already calculated sizes by path for directories that are still present, and calls it in thedirChanhandler when an existing directory is replaced (before sorting, sosortby sizekeeps using them).Testing
TestCopyDirSizesinnav_test.go. With a no-op helper it fails (at "a" expected dirSize 42 but got -1), and passes with the fix.map C :set dircounts false; calcdirsizeand pressingConce: onmasterthe directory shows-, with this change it shows3.0M.go fmt,go vet ./...,GOOS=windows go vet ./...,go test ./...,golangci-lint run ./...(0 issues).This change was investigated and written with the help of an AI assistant (Claude Code); the checks above were run locally.
🤖 Generated with Claude Code