mirror of
https://github.com/docker/docs.git
synced 2026-04-12 06:19:22 +07:00
Merge pull request #176 from kitematic/setup-cancel
Change re-run to retry in setup
This commit is contained in:
@@ -28,7 +28,7 @@ var Setup = React.createClass({
|
||||
SetupStore.removeListener(SetupStore.ERROR_EVENT, this.update);
|
||||
},
|
||||
handleRetry: function () {
|
||||
SetupStore.run().catch(() => {});
|
||||
SetupStore.retry();
|
||||
},
|
||||
handleOpenWebsite: function () {
|
||||
Util.exec(['open', 'https://www.virtualbox.org/wiki/Downloads']);
|
||||
|
||||
@@ -12,6 +12,7 @@ var SUDO_PROMPT = 'Kitematic requires administrative privileges to install Virtu
|
||||
var _currentStep = null;
|
||||
var _error = null;
|
||||
var _cancelled = false;
|
||||
var _retryPromise = null;
|
||||
|
||||
var _steps = [{
|
||||
name: 'downloadVirtualBox',
|
||||
@@ -55,8 +56,7 @@ var _steps = [{
|
||||
try {
|
||||
yield util.exec(sudoCmd);
|
||||
} catch (err) {
|
||||
_cancelled = true;
|
||||
throw err;
|
||||
throw null;
|
||||
}
|
||||
})
|
||||
}, {
|
||||
@@ -132,30 +132,48 @@ var SetupStore = assign(EventEmitter.prototype, {
|
||||
cancelled: function () {
|
||||
return _cancelled;
|
||||
},
|
||||
run: Promise.coroutine(function* () {
|
||||
retry: function () {
|
||||
_error = null;
|
||||
_cancelled = false;
|
||||
var steps = _currentStep ? _steps.slice(_steps.indexOf(_currentStep)) : _steps;
|
||||
for (let step of steps) {
|
||||
_retryPromise.resolve();
|
||||
},
|
||||
wait: function () {
|
||||
_retryPromise = Promise.defer();
|
||||
return _retryPromise.promise;
|
||||
},
|
||||
run: Promise.coroutine(function* () {
|
||||
var exists = yield boot2docker.exists();
|
||||
if (exists) {
|
||||
this.steps().startBoot2Docker.seconds = 13;
|
||||
}
|
||||
|
||||
for (let step of _steps) {
|
||||
_currentStep = step;
|
||||
step.percent = 0;
|
||||
try {
|
||||
console.log(step.name);
|
||||
this.emit(this.STEP_EVENT);
|
||||
yield step.run(percent => {
|
||||
if (_currentStep) {
|
||||
step.percent = percent;
|
||||
this.emit(this.PROGRESS_EVENT);
|
||||
while (true) {
|
||||
try {
|
||||
this.emit(this.STEP_EVENT);
|
||||
yield step.run(percent => {
|
||||
if (_currentStep) {
|
||||
step.percent = percent;
|
||||
this.emit(this.PROGRESS_EVENT);
|
||||
}
|
||||
});
|
||||
step.percent = 100;
|
||||
break;
|
||||
} catch (err) {
|
||||
if (err) {
|
||||
_error = err;
|
||||
this.emit(this.ERROR_EVENT);
|
||||
} else {
|
||||
_cancelled = true;
|
||||
this.emit(this.STEP_EVENT);
|
||||
}
|
||||
});
|
||||
step.percent = 100;
|
||||
} catch (err) {
|
||||
console.log(err.stack);
|
||||
_error = err;
|
||||
this.emit(this.ERROR_EVENT);
|
||||
throw err;
|
||||
yield this.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
_currentStep = null;
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user