Skip to content

fs: ignore disappearing files in DiskUsage - #335

Open
Soundcreates wants to merge 1 commit into
containerd:mainfrom
Soundcreates:fix/disk-usage-disappearing-files-332
Open

Soundcreates wants to merge 1 commit into
containerd:mainfrom
Soundcreates:fix/disk-usage-disappearing-files-332

Conversation

@Soundcreates

Copy link
Copy Markdown

Closes #332.

DiskUsage can fail when a descendant disappears after its parent directory is read. This skips ENOENT for descendants in both Unix and Windows walks while preserving errors for a missing root and other failures.

Tests: go test ./... and git diff --check.

A file or directory can disappear after filepath.Walk reads its parent but before the entry is inspected. Treat ENOENT for descendants as a transient condition because the removed entry no longer contributes to disk usage.

Keep returning errors for a missing root and for all other walk failures. Apply the behavior on Unix and Windows and cover the error handling with regression tests.

Assisted-by: OpenAI Codex
Signed-off-by: Shantanav Mukherjee <shantanav7@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.DiskUsage fails when a file is deleted during the walk (lstat/readdirent: no such file or directory)

1 participant