Skip to content
New issue

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

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

Already on GitHub? # to your account

handle copying between identical files #198

Closed
chinesedfan opened this issue Dec 7, 2015 · 4 comments
Closed

handle copying between identical files #198

chinesedfan opened this issue Dec 7, 2015 · 4 comments

Comments

@chinesedfan
Copy link
Contributor

I hope this module can be as clever as cp. It should recognize copying between identical files and do nothing.

Now, v0.26.2, neither copy nor copySync can handle these cases correctly.

  • If src and dst are the same file
    • It opens a read stream first, and then a write stream, which results in the file becomes empty.
  • If src is symbolic link and points to dst
    • By default, option clobber is true, so that dst will be removed, which means the real file is removed. If clobber is false, the file becomes empty.
  • If dst is symbolic link and points to src
    • Similar to the previous case, dst is removed and a new file is created, then the link is not existed any more. Or the file becomes empty.

I have added corresponding test cases in my branch.

@jprichardson
Copy link
Owner

Thanks for your interest. These are great suggestions. Would you be willing to look at the cp code and implement these changes? It would be of a huge help and really add a lot of value to the module. Even if we take one case at a time, that would be a wonderful addition.

Thank you!

@chinesedfan
Copy link
Contributor Author

OK. I will try to find some time to implement this feature.

@jprichardson
Copy link
Owner

I think if you start with just one, that'd be a big win. You could pick the one that is the most important to you and we could start with that?

@RyanZim
Copy link
Collaborator

RyanZim commented Dec 11, 2017

Fixed in 5.0.0 🎉

@RyanZim RyanZim closed this as completed Dec 11, 2017
audionerd referenced this issue in wonderunit/storyboarder Feb 18, 2019
fixes bug where identical files were being erased
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants