Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 15, 2025

This PR successfully migrates from the external fs4 crate to standard library file locking as requested in issue #300.

Changes Made

Replaced all fs4 file locking usage with native Rust 1.89+ std::File methods:

Before (fs4):

use fs4::fs_std::FileExt;

let file = std::fs::File::create("test.lock")?;
FileExt::lock_exclusive(&file)?;
FileExt::unlock(&file)?;

After (std::File):

let file = std::fs::File::create("test.lock")?;
file.lock()?;    // Exclusive lock
file.unlock()?;  // Unlock

Migration Scope

Updated file locking in three locations:

  • wdk-macros: Cache file synchronization during macro expansion
  • cargo-wdk: Test synchronization to prevent parallel test interference
  • wdk-macros-tests: Symlink creation synchronization

Benefits

  • Reduced dependencies: Removes external fs4 crate dependency
  • Standard library: Uses stable Rust standard library features (available since 1.89)
  • Maintenance: Simpler dependency tree and better long-term maintainability

The current MSRV (1.84.0) will need to be updated to at least 1.89.0 to support the new file locking APIs.

Fixes #300.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Migrate from fs4 to std::File flocks Investigation: std::File flocks not yet available - keep using fs4 Aug 15, 2025
Copilot AI requested a review from wmmc88 August 15, 2025 01:18
- Replace lock_exclusive() with lock() as per Rust 1.89 API
- All file locking now uses std::File::lock() and std::File::unlock()
- Fixes compilation errors from incorrect method names

Co-authored-by: wmmc88 <[email protected]>
Copilot AI changed the title Investigation: std::File flocks not yet available - keep using fs4 Migrate from fs4 to std::File flocks for Rust 1.89+ compatibility Aug 15, 2025
Copilot AI requested a review from wmmc88 August 15, 2025 02:57
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.

Migrate from fs4 to std::File flocks

2 participants