Merge branch 'MarshallOfSound-master'
This commit is contained in:
commit
570dc7ca9b
2 changed files with 22 additions and 4 deletions
|
@ -22,6 +22,12 @@ SQRLUpdater* g_updater = nil;
|
|||
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
|
||||
bool g_update_available = false;
|
||||
|
||||
}
|
||||
|
||||
// static
|
||||
void AutoUpdater::SetFeedURL(const std::string& feed) {
|
||||
if (g_updater == nil) {
|
||||
|
@ -69,6 +75,7 @@ void AutoUpdater::CheckForUpdates() {
|
|||
take:1]
|
||||
subscribeNext:^(SQRLDownloadedUpdate *downloadedUpdate) {
|
||||
if (downloadedUpdate) {
|
||||
g_update_available = true;
|
||||
SQRLUpdate* update = downloadedUpdate.update;
|
||||
// There is a new update that has been downloaded.
|
||||
delegate->OnUpdateDownloaded(
|
||||
|
@ -77,6 +84,7 @@ void AutoUpdater::CheckForUpdates() {
|
|||
base::Time::FromDoubleT(update.releaseDate.timeIntervalSince1970),
|
||||
base::SysNSStringToUTF8(update.updateURL.absoluteString));
|
||||
} else {
|
||||
g_update_available = false;
|
||||
// When the completed event is sent with no update, then we know there
|
||||
// is no update available.
|
||||
delegate->OnUpdateNotAvailable();
|
||||
|
@ -89,11 +97,16 @@ void AutoUpdater::CheckForUpdates() {
|
|||
}
|
||||
|
||||
void AutoUpdater::QuitAndInstall() {
|
||||
[[g_updater relaunchToInstallUpdate] subscribeError:^(NSError* error) {
|
||||
Delegate* delegate = AutoUpdater::GetDelegate();
|
||||
Delegate* delegate = AutoUpdater::GetDelegate();
|
||||
if (g_update_available) {
|
||||
[[g_updater relaunchToInstallUpdate] subscribeError:^(NSError* error) {
|
||||
if (delegate)
|
||||
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription));
|
||||
}];
|
||||
} else {
|
||||
if (delegate)
|
||||
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription));
|
||||
}];
|
||||
delegate->OnError("No update available, can't quit and install");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace auto_updater
|
||||
|
|
|
@ -12,6 +12,9 @@ function AutoUpdater () {
|
|||
util.inherits(AutoUpdater, EventEmitter)
|
||||
|
||||
AutoUpdater.prototype.quitAndInstall = function () {
|
||||
if (!this.updateAvailable) {
|
||||
return this.emitError('No update available, can\'t quit and install')
|
||||
}
|
||||
squirrelUpdate.processStart()
|
||||
return app.quit()
|
||||
}
|
||||
|
@ -33,8 +36,10 @@ AutoUpdater.prototype.checkForUpdates = function () {
|
|||
return this.emitError(error)
|
||||
}
|
||||
if (update == null) {
|
||||
this.updateAvailable = false
|
||||
return this.emit('update-not-available')
|
||||
}
|
||||
this.updateAvailable = true
|
||||
this.emit('update-available')
|
||||
squirrelUpdate.update(this.updateURL, (error) => {
|
||||
var date, releaseNotes, version
|
||||
|
|
Loading…
Reference in a new issue