Skip to content

refactor(pm): simplify Linux cloner with sync hardlink strategy - #2567

Merged
elrrrrrrr merged 8 commits into
nextfrom
feat/simplify-cloner
Feb 3, 2026
Merged

refactor(pm): simplify Linux cloner with sync hardlink strategy#2567
elrrrrrrr merged 8 commits into
nextfrom
feat/simplify-cloner

Conversation

@elrrrrrrr

Copy link
Copy Markdown
Contributor
  • The previous implementation tried FICLONE ioctl, then copy_file_range,
    then regular copy - each with separate spawn_blocking calls.

  • This simplification uses hardlinks (which are fast and share disk space)
    with copy fallback, all in a single blocking task.

@elrrrrrrr elrrrrrrr added the A-Pkg Manager Area: Package Manager label Feb 3, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @elrrrrrrr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the file cloning utility, specifically for Linux, to simplify its implementation and improve efficiency. The previous complex multi-stage asynchronous copying mechanism has been replaced with a more straightforward synchronous approach that leverages hardlinks for performance and disk space efficiency, falling back to a direct copy when necessary. This change consolidates blocking I/O operations into a single task, reducing overhead and making the cloning process more robust. Minor structural improvements were also applied to the Windows cloner for consistency.

Highlights

  • Linux Cloner Simplification: The Linux file cloning logic has been significantly simplified by removing complex asynchronous fallback mechanisms (FICLONE, copy_file_range) and adopting a synchronous hardlink-first strategy with a regular copy fallback.
  • Synchronous Hardlink Strategy: The new Linux implementation prioritizes creating hardlinks for files to save disk space and improve performance. If hardlinking fails, it falls back to a standard file copy.
  • Consolidated Blocking Operations: Instead of multiple spawn_blocking calls for different copy methods, the entire directory cloning process on Linux is now handled within one blocking task, streamlining execution.
  • Windows Cloner Refinement: The Windows cloner also received minor refactoring, separating the initial directory creation from the recursive copying logic for both fast_copy and clone_dir functions, improving code structure.
Changelog
  • crates/pm/src/util/cloner.rs
    • Removed FICLONE and copy_file_range specific logic and related feature flags.
    • Introduced synchronous helper functions (has_install_script_sync, copy_file_sync, clone_dir_sync).
    • Refactored the main linux_clone::clone_dir to use a single spawn_blocking call for the entire cloning process.
    • Updated windows_clone::fast_copy and windows_clone::clone_dir to use internal recursive helper functions (fast_copy_inner, clone_dir_inner) for better structure.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request significantly simplifies the file cloning logic for Linux by replacing a complex, multi-stage async implementation with a much cleaner synchronous approach using hardlinks and a copy fallback, all executed within a tokio::task::spawn_blocking call. This is a great improvement for readability and maintainability. The related refactoring in the Windows implementation also improves the code structure. My feedback focuses on enhancing error handling to make the cloning process more robust and improving the formatting of error messages for better diagnostics.

Comment thread crates/pm/src/util/cloner.rs Outdated
Comment thread crates/pm/src/util/cloner.rs Outdated
Comment thread crates/pm/src/util/cloner.rs Outdated
Comment thread crates/pm/src/util/cloner.rs Outdated
elrrrrrrr and others added 2 commits February 3, 2026 15:03
- Only ignore AlreadyExists errors instead of silently ignoring all errors
- Use .display() for path formatting in error messages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment thread crates/pm/src/util/cloner.rs Outdated
elrrrrrrr and others added 3 commits February 3, 2026 17:15
Use is_some_and and is_ok_and for more idiomatic Rust.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use is_ok_and for Result -> bool patterns
- Use is_some_and for Option -> bool patterns
- Use map_or for Option with default value patterns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@elrrrrrrr
elrrrrrrr force-pushed the feat/simplify-cloner branch from 40d4cc1 to dd9a9ce Compare February 3, 2026 09:40
@elrrrrrrr
elrrrrrrr merged commit 2041da6 into next Feb 3, 2026
18 checks passed
@elrrrrrrr
elrrrrrrr deleted the feat/simplify-cloner branch February 3, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Pkg Manager Area: Package Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants