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

Unified Diff: editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/jobs/InstallUpdateAction.java

Issue 596793002: continue update even if user has deleted executable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and check that executable exists before rename Created 6 years, 3 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: editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/jobs/InstallUpdateAction.java
diff --git a/editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/jobs/InstallUpdateAction.java b/editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/jobs/InstallUpdateAction.java
index 5476a9cd07ac73a3040a01d5afb3acc41e625717..25ba5d149b24919ccd13a2b4c424cd00244d8786 100644
--- a/editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/jobs/InstallUpdateAction.java
+++ b/editor/tools/plugins/com.google.dart.tools.update.core/src/com/google/dart/tools/update/core/internal/jobs/InstallUpdateAction.java
@@ -58,6 +58,12 @@ public class InstallUpdateAction extends Action {
* cleaned up after update.
*/
private static class Executable {
+ static void add(List<Executable> list, String name, File executable) {
+ if (executable != null) {
+ list.add(new Executable(name, executable));
+ }
+ }
+
private final String name;
private final File executable;
private final File oldExecutable;
@@ -84,7 +90,7 @@ public class InstallUpdateAction extends Action {
}
boolean rename() {
- return deleteOld() && executable.renameTo(oldExecutable);
+ return !executable.exists() || (deleteOld() && executable.renameTo(oldExecutable));
}
void restore() {
@@ -187,16 +193,16 @@ public class InstallUpdateAction extends Action {
}
DirectoryBasedDartSdk sdk = DartSdkManager.getManager().getSdk();
- Executable[] executables = new Executable[] {
- new Executable("Dart VM", sdk.getVmExecutable()),
- new Executable("Dartium", sdk.getDartiumExecutable())};
+ List<Executable> executables = new ArrayList<Executable>();
+ Executable.add(executables, "Dart VM", sdk.getVmExecutable());
+ Executable.add(executables, "Dartium", sdk.getDartiumExecutable());
int index = 0;
- while (index < executables.length) {
- if (!executables[index].rename()) {
- Executable failedRename = executables[index];
+ while (index < executables.size()) {
+ if (!executables.get(index).rename()) {
+ Executable failedRename = executables.get(index);
--index;
while (index >= 0) {
- executables[index].restore();
+ executables.get(index).restore();
--index;
}
MessageDialog.openError(
« 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