-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Do not remove dest file on File.cp error #3156
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
Conversation
@@ -607,8 +607,6 @@ defmodule File do | |||
[dest|acc] | |||
{:error, :eexist} -> | |||
if callback.(src, dest) do | |||
# If rm/1 fails, copy/2 will fail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your comment is true here, because the previous copy was ran with exclusive mode.
@josevalim what is the purpose of trying low level The problem discussed here cannot be solved by simply removing the call the rm/2 because the subsequent call to copy/3 does not result in error but creates an empty file. Summary:
Next?
|
So the bug is in Erlang copy implementation. :( I have no idea what to do next then. Maybe we should expand the paths ourselves and check if they are not equal. |
I have posted a question on erlang mailing list regarding this. https://groups.google.com/forum/#!topic/erlang-questions/q2BjcwC58j8 . Can this wait until something is heard from erlang end or we go ahead and implement a condition checking src and dest? Also to keep in mind is that this issue with copying src to src is affecting all cp* functions including cp_r!/3 cp_r/3 etc, though the actual error is different in each of them. |
Seems like nobody has responded in Erlang Questions group; it could not probably be a bug as |
@lexmag checking the paths may be a better way to go indeed. |
@lexmag pls proceed. thank you. |
CLosing, thank you. |
Fixes #3155
Actually I have removed the 'rm' calls in
do_cp_file
anddo_cp_link
as I believe erlang takes care of not creating a file residue in case of failure. However, if that's not the case, either a bug report in erlang should be created or we have to delete the file conditionally only when the dest is not the same as src.