Skip to content

fix(desktop bindings): report unknown directory-entry sizes as zero - #808

Merged
sanchitmonga22 merged 2 commits into
RunanywhereAI:mainfrom
shubhamsinnh:fix/desktop-unknown-directory-entry-sizes
Sep 11, 2026
Merged

fix(desktop bindings): report unknown directory-entry sizes as zero#808
sanchitmonga22 merged 2 commits into
RunanywhereAI:mainfrom
shubhamsinnh:fix/desktop-unknown-directory-entry-sizes

Conversation

@shubhamsinnh

@shubhamsinnh shubhamsinnh commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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 to int64_t, allowing -1 to escape even though rac_directory_entry_t::size_bytes requires 0 for directories or unknown sizes.

Fix

  • set size_bytes to 0 whenever the size lookup reports an error
  • apply the same fallback to Electron and Python on Windows and POSIX
  • preserve successful regular-file sizes and existing directory enumeration behavior

Scope

  • bindings/electron/native/win32_platform_adapter.cpp
  • bindings/electron/native/posix_platform_adapter.cpp
  • bindings/python/native/win32_platform_adapter.cpp
  • bindings/python/native/posix_platform_adapter.cpp

Validation

  • git diff --check
  • targeted formatting checks for every changed range
  • C++20 syntax compilation of both Win32 adapter translation units
  • Electron Windows/macOS and Python Windows/macOS CI passed

POSIX 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

  • Bug Fixes
    • Improved directory listings when file-size information cannot be retrieved.
    • Entries with unavailable or invalid size data now report a size of zero instead of potentially displaying an incorrect value.
    • Applied consistently across supported desktop and Python integrations.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 555e022e-ae5b-416d-8631-2d1052426c78

📥 Commits

Reviewing files that changed from the base of the PR and between 45e9127 and 01a7e72.

📒 Files selected for processing (4)
  • bindings/electron/native/posix_platform_adapter.cpp
  • bindings/electron/native/win32_platform_adapter.cpp
  • bindings/python/native/posix_platform_adapter.cpp
  • bindings/python/native/win32_platform_adapter.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

Directory listing adapters for Electron and Python now set size_bytes to zero when file-size retrieval reports an error on POSIX or Win32.

Changes

Directory Size Handling

Layer / File(s) Summary
Zero size on retrieval errors
bindings/electron/native/*_platform_adapter.cpp, bindings/python/native/*_platform_adapter.cpp
POSIX and Win32 directory listing functions now assign zero to size_bytes when file-size operations report errors.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 01a7e

The adapters consistently preserve successful sizes and report zero when size lookup fails.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: desktop bindings now report unknown directory-entry sizes as zero.
Description check ✅ Passed The description explains the problem, fix, scope, and validation. It covers the main required information, including platform coverage and the unavailable POSIX local environment. It does not use the …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@shubhamsinnh
shubhamsinnh marked this pull request as ready for review August 27, 2026 14:25
@sanchitmonga22

Copy link
Copy Markdown
Contributor

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@sanchitmonga22 sanchitmonga22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sanchitmonga22
sanchitmonga22 merged commit 8623796 into RunanywhereAI:main Sep 11, 2026
30 checks passed
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.

2 participants