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

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: Redo after syncing. 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 a190c1ba3cdb6be618a7f8a270ffc4909d47a96c..f6894160753067bd21a2301a2c5e79c8ac0a09aa 100644
--- a/utils/pub/entrypoint.dart
+++ b/utils/pub/entrypoint.dart
@@ -298,10 +298,16 @@ class Entrypoint {
Future _linkSecondaryPackageDir(String dir) {
return defer(() {
var symlink = path.join(dir, 'packages');
- 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.
+ // TODO(rnystrom): Make deleteFile() work for symlinks on Windows so this
+ // doesn't matter.
+ if (dirExists(symlink)) {
deleteDir(symlink);
+ } else if (fileExists(symlink)) {
+ deleteFile(symlink);
}
return 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