fix(desktop bindings): report unknown directory-entry sizes as zero - #808
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughDirectory listing adapters for Electron and Python now set ChangesDirectory Size Handling
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to The adapters consistently preserve successful sizes and report zero when size lookup fails. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
sanchitmonga22
left a comment
There was a problem hiding this comment.
Thanks a lot for this, @shubhamsinnh! This makes the Electron and Python desktop directory listings report 0 (per the documented contract) instead of -1 when a file's size can't be read — for example a broken symlink, FIFO, or socket.
Checked: CodeRabbit reviewed the latest commit · CI green · built and linted locally merged into main (electron native addon + TS build/test, Python test suite) · two independent code reviews.
Follow-ups, not blocking: #890 (sharing the four hand-kept list_dir bindings' error handling with the core desktop adapter) — you're welcome to pick it up.
Merging now — really appreciate the contribution!
Reviewed with help from Claude Code and Codex.
Problem
std::filesystem::file_size(path, error_code)returns an error sentinel when an entry size cannot be determined. The Electron and Python desktop adapters cast that sentinel toint64_t, allowing-1to escape even thoughrac_directory_entry_t::size_bytesrequires0for directories or unknown sizes.Fix
size_bytesto0whenever the size lookup reports an errorScope
bindings/electron/native/win32_platform_adapter.cppbindings/electron/native/posix_platform_adapter.cppbindings/python/native/win32_platform_adapter.cppbindings/python/native/posix_platform_adapter.cppValidation
git diff --checkPOSIX compilation was not available locally because this Windows host has no Linux or WSL environment; the macOS binding jobs provide the corresponding platform compile coverage.
Summary by CodeRabbit