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

Unified Diff: utils/pub/entrypoint.dart

Issue 12716024: Handle deleting broken symlinks on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | utils/tests/pub/pub.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/entrypoint.dart
diff --git a/utils/pub/entrypoint.dart b/utils/pub/entrypoint.dart
index a6afb14a2109bce79ffd3a9b0aef6481ef243e1c..fbe97c7529f666a83dccb7c498d355f76bf2f05b 100644
--- a/utils/pub/entrypoint.dart
+++ b/utils/pub/entrypoint.dart
@@ -297,10 +297,14 @@ class Entrypoint {
return defer(() {
var symlink = path.join(dir, 'packages');
return new Future.of(() {
- if (fileExists(symlink)) {
- deleteFile(symlink);
- } else if (dirExists(symlink)) {
+ // The order of if tests is significant here. fileExists() will return
+ // true for a symlink (broken or not) but deleteFile() cannot be used
+ // to delete a broken symlink on Windows. So we test for the directory
+ // first since deleteDir() does work on symlinks.
nweiz 2013/03/19 19:41:02 Can we clean up these semantics in io.dart? I'd li
+ if (dirExists(symlink)) {
return deleteDir(symlink);
+ } else if (fileExists(symlink)) {
+ deleteFile(symlink);
}
}).then((_) => createSymlink(packagesDir, symlink, relative: true));
});
« no previous file with comments | « no previous file | utils/tests/pub/pub.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698