-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Directory.rename
should not delete the target if it exists
#47653
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
Comments
/cc @mit-mit @devoncarew |
Thanks for filing the breaking change request; I'll track down approvals (as per https://github.com/dart-lang/sdk/blob/master/docs/process/breaking-changes.md#step-2-approval). |
FWIW, this seems like a reasonable change to me. |
Hey @devoncarew , you'll comment again on this issue when I have approval, right? |
Thanks, yup. I'm still running down some details of our breaking change process. I think we'll want approval from AngularDart (and google3 impact), Flutter, and Dart generally. @grouma, @Hixie, and @vsmenon - can you review and approve? I suspect the impact of the change will be relatively low, and will be specific to Windows. Thanks! |
It looks like we have the same 'overwrite' behaviour for file renames? Do we want to change them both? And do we want to consider still overwriting, perhaps via a extra optional parameter, e.g.: |
Hey @mit-mit ,
|
This should have no impact on AngularDart since it requires |
lgtm |
So am I good to go? |
We should get feedback from @Hixie (though I don't suspect this will impact Flutter apps). |
This change seems positive. In general, the less we silently delete, the better. Also, the more these I/O operations can approximate an atomic operation, the more reliable they will be in general. |
Thanks all! @brianquinlan, I think you can consider this change approved. From https://github.com/dart-lang/sdk/blob/master/docs/process/breaking-changes.md, you want to send an announce email to |
I've made the announcement and added an update to the change log to my CL. I'll wait until mid next week to submit. |
Fixed in 0e5f3f4 |
made in 0e5f3f4 Change-Id: Ic7e9a91512661d3a1999f933e9d6caab6db340a1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220700 Reviewed-by: Kevin Moore <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Brian Quinlan <[email protected]>
Change
Currently
Directory.rename()
has two undesirable properties on Windows:I propose that we remove both of those behaviors i.e. it is an no-op if the src and target paths are identical and it is an error if the target path is an existing directory.
See https://dart-review.googlesource.com/c/sdk/+/219501
Rationale
This change will bring the semantics of
Directory.rename()
on Windows inline with the semantics on every other platform - except that it will be an error torename
to a existing empty directory, which is allowed on POSIX systems.This is inline with the behavior offered in other programming languages:
https://en.cppreference.com/w/cpp/filesystem/rename
https://docs.python.org/3/library/os.html#os.rename
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#renameTo(java.io.File)
https://doc.rust-lang.org/std/fs/fn.rename.html
Impact
It is possible (but not likely IMO) that some dart Windows-only programs rely on this behavior but it is more likely that existing programs have a large unintended footgun and this will remove it.
Mitigation
Users can first remove the target directory before
rename
i.e.The text was updated successfully, but these errors were encountered: