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

fix: unexpected abort when symlink to non-regular file #1383

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fourdim
Copy link

@fourdim fourdim commented Sep 14, 2024

std::fs::copy will return an error when

Error screenshot:
image

Windows part is not tested.

#[cfg(unix)]
{
if target.is_absolute() && target.starts_with(from) {
symlink_file(target.strip_prefix(from).unwrap(), &destination)
Copy link
Member

Choose a reason for hiding this comment

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

Why is the strip_prefix here necessary?

Copy link
Author

Choose a reason for hiding this comment

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

For example:
If we have a folder symlink:

/project/folder -> /project/folder2

And we want to copy it to /tmp,
It is apparently we don't want this:

/tmp/folder -> /project/folder2

This one is more reasonable, isn't it?

/tmp/folder -> ./folder2

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