Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail reflink_or_copy if target file already exist #81

Merged
merged 4 commits into from
Nov 3, 2024

Conversation

Vaiz
Copy link

@Vaiz Vaiz commented Nov 3, 2024

This might be a controversial take, so I decided to create a separate PR.

The reflink function fails if the target file exists, whereas reflink_or_copy switches to copying. As a result, instead of saving space when possible, the function creates a full copy. I see two solutions for this problem:

  • Make reflink_or_copy act like reflink and return an error if the target file exists.
  • Rewrite the function to clone blocks even if the target file exists.

This PR implements the first solution, making reflink_or_copy return an error if the target file exists. I also added a few other unrecoverable errors to the list.

Copy link
Member

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

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

Thanks I think this absolutely makes sense.

reflink_copy shall fallback to std::fs::copy if reflink isn't available, but should not fallback on permission error/dest file already exists/source file not exist.

@NobodyXu NobodyXu merged commit 9e0b2cf into cargo-bins:main Nov 3, 2024
18 checks passed
@github-actions github-actions bot mentioned this pull request Nov 3, 2024
@Vaiz Vaiz deleted the early_fail branch November 9, 2024 10:55
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