[PR #4851] [MERGED] Fix the Windows build: free disk space without unsafe code #5892

Closed
opened 2026-11-03 05:15:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4851
Author: @levzzz5154
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: fix/win-disk-space-unsafe


📝 Commits (1)

  • bc10539 Fix the Windows build: read free disk space without unsafe code

📊 Changes

3 files changed (+14 additions, -37 deletions)

View changed files

📝 Cargo.lock (+11 -0)
📝 crates/horizon-client/Cargo.toml (+2 -1)
📝 crates/horizon-client/src/save.rs (+1 -36)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally.

What and why

#4732 added estimate_disk_space (vanilla's LevelStorageAccess.estimateDiskSpace) with a Windows branch that called GetDiskFreeSpaceExW through an unsafe extern block. The client lib is #![forbid(unsafe_code)], so every Windows build fails:

error: usage of an `unsafe extern` block
   --> crates/horizon-client/src/save.rs:282:9
error: usage of an `unsafe` block
   --> crates/horizon-client/src/save.rs:293:18

Linux CI never compiles the cfg(windows) branch, so verify passed. This replaces both platform branches with fs4::available_space (safe, rustix on Unix, windows-sys on Windows), so Linux CI now compiles the code Windows runs.

Self-check

  • Reproduced the two errors with cargo check -p horizon-client --lib --target x86_64-pc-windows-gnu --no-default-features on main; with this PR, --lib --bins for that target checks clean.
  • fmt, clippy -p horizon-client --lib -D warnings, cargo test -p horizon-client --lib save:: (43 passed).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4851 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/win-disk-space-unsafe` --- ### 📝 Commits (1) - [`bc10539`](https://github.com/horizon-rust/horizon/commit/bc105393f06f415638e1e1e43e3ecd2714bcf946) Fix the Windows build: read free disk space without unsafe code ### 📊 Changes **3 files changed** (+14 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+11 -0) 📝 `crates/horizon-client/Cargo.toml` (+2 -1) 📝 `crates/horizon-client/src/save.rs` (+1 -36) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. ## What and why #4732 added `estimate_disk_space` (vanilla's `LevelStorageAccess.estimateDiskSpace`) with a Windows branch that called `GetDiskFreeSpaceExW` through an `unsafe extern` block. The client lib is `#![forbid(unsafe_code)]`, so every Windows build fails: ``` error: usage of an `unsafe extern` block --> crates/horizon-client/src/save.rs:282:9 error: usage of an `unsafe` block --> crates/horizon-client/src/save.rs:293:18 ``` Linux CI never compiles the `cfg(windows)` branch, so `verify` passed. This replaces both platform branches with `fs4::available_space` (safe, rustix on Unix, windows-sys on Windows), so Linux CI now compiles the code Windows runs. ## Self-check - Reproduced the two errors with `cargo check -p horizon-client --lib --target x86_64-pc-windows-gnu --no-default-features` on main; with this PR, `--lib --bins` for that target checks clean. - fmt, `clippy -p horizon-client --lib -D warnings`, `cargo test -p horizon-client --lib save::` (43 passed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:43 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5892
No description provided.