Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Unified Diff: sdk/lib/_internal/pub/lib/src/io.dart

Issue 22799008: Ensure that renames fail atomically in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/io.dart
diff --git a/sdk/lib/_internal/pub/lib/src/io.dart b/sdk/lib/_internal/pub/lib/src/io.dart
index 91d98805143319bc9cca786cc1f329f7d773dd2e..5847fedfed3bc277ab3ac5d8ab6e171e10169bef 100644
--- a/sdk/lib/_internal/pub/lib/src/io.dart
+++ b/sdk/lib/_internal/pub/lib/src/io.dart
@@ -309,7 +309,13 @@ void cleanDir(String dir) {
/// Renames (i.e. moves) the directory [from] to [to].
void renameDir(String from, String to) {
log.io("Renaming directory $from to $to.");
- new Directory(from).renameSync(to);
+ try {
+ new Directory(from).renameSync(to);
+ } on IOException catch (error) {
+ // Ensure that [to] isn't left in an inconsistent state. See issue 12436.
+ if (entryExists(to)) deleteEntry(to);
+ rethrow;
+ }
}
/// Creates a new symlink at path [symlink] that points to [target]. Returns a
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698