mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-25 17:05:39 +01:00
Make launcher mode behaviour more robust
This commit is contained in:
parent
9a28807423
commit
e69443c22e
@ -12,6 +12,7 @@ use log::Level;
|
||||
enum CallbackType {
|
||||
SelectInstallDir { callback_name: String },
|
||||
Log { msg: String, kind: String },
|
||||
Test {}
|
||||
}
|
||||
|
||||
/// Starts the main web UI. Will return when UI is closed.
|
||||
@ -58,9 +59,11 @@ pub fn start_ui(app_name: &str, http_address: &str, is_launcher: bool) {
|
||||
_ => Level::Error,
|
||||
};
|
||||
|
||||
log!(target: "liftinstall::frontend-js", kind, "{}", msg);
|
||||
log!(target: "liftinstall::frontend::js", kind, "{}", msg);
|
||||
}
|
||||
CallbackType::Test {} => {}
|
||||
}
|
||||
|
||||
cb_result
|
||||
})
|
||||
.run()
|
||||
|
@ -82,8 +82,6 @@ pub struct InstallerFramework {
|
||||
// If we just completed an uninstall, and we should clean up after ourselves.
|
||||
pub burn_after_exit: bool,
|
||||
pub launcher_path: Option<String>,
|
||||
|
||||
attempted_shutdown: bool,
|
||||
}
|
||||
|
||||
/// Contains basic properties on the status of the session. Subset of InstallationFramework.
|
||||
@ -400,27 +398,22 @@ impl InstallerFramework {
|
||||
|
||||
/// Shuts down the installer instance.
|
||||
pub fn shutdown(&mut self) -> Result<(), String> {
|
||||
if self.attempted_shutdown {
|
||||
return Err("Cannot attempt shutdown twice!".to_string());
|
||||
}
|
||||
|
||||
self.attempted_shutdown = true;
|
||||
|
||||
info!("Shutting down installer framework...");
|
||||
|
||||
if let Some(ref v) = self.launcher_path {
|
||||
if let Some(ref v) = self.launcher_path.take() {
|
||||
info!("Launching {:?}", v);
|
||||
|
||||
Command::new(v)
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()
|
||||
.map_err(|x| format!("Unable to start child process: {:?}", x))?;
|
||||
.map_err(|x| format!("Unable to start application: {:?}", x))?;
|
||||
}
|
||||
|
||||
if self.burn_after_exit {
|
||||
info!("Requesting that self be deleted after exit.");
|
||||
native::burn_on_exit(&self.base_attributes.name);
|
||||
self.burn_after_exit = false;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -437,7 +430,6 @@ impl InstallerFramework {
|
||||
is_launcher: false,
|
||||
burn_after_exit: false,
|
||||
launcher_path: None,
|
||||
attempted_shutdown: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,7 +457,6 @@ impl InstallerFramework {
|
||||
is_launcher: false,
|
||||
burn_after_exit: false,
|
||||
launcher_path: None,
|
||||
attempted_shutdown: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,20 @@ function intercept (method) {
|
||||
}
|
||||
}
|
||||
|
||||
// See if we have access to the JSON interface
|
||||
var has_external_interface = false;
|
||||
try {
|
||||
window.external.invoke(JSON.stringify({
|
||||
Test: {}
|
||||
}))
|
||||
has_external_interface = true;
|
||||
} catch (e) {
|
||||
console.warn("Running without JSON interface - unexpected behaviour may occur!")
|
||||
}
|
||||
|
||||
// Overwrite loggers with the logging backend
|
||||
if (window.external !== undefined && window.external.invoke !== undefined) {
|
||||
if (has_external_interface) {
|
||||
window.onerror = function (msg, url, line) {
|
||||
old_onerror(msg, url, line)
|
||||
window.external.invoke(
|
||||
JSON.stringify({
|
||||
Log: {
|
||||
@ -89,12 +99,13 @@ var app = new Vue({
|
||||
'/api/exit',
|
||||
function () {},
|
||||
function (msg) {
|
||||
alert(
|
||||
'LiftInstall encountered an error while exiting: ' +
|
||||
msg +
|
||||
'\nPlease upload the log file (in the same directory as the installer) to ' +
|
||||
'the respective maintainers for this application (where you got it from!)'
|
||||
)
|
||||
var search_location = app.metadata.install_path.length > 0 ? app.metadata.install_path :
|
||||
"the location where this installer is";
|
||||
|
||||
app.$router.replace({ name: 'showerr', params: { msg: msg +
|
||||
'\n\nPlease upload the log file (in ' + search_location + ') to ' +
|
||||
'the ' + app.attrs.name + ' team'
|
||||
}});
|
||||
}
|
||||
)
|
||||
},
|
||||
@ -102,3 +113,5 @@ var app = new Vue({
|
||||
stream_ajax: stream_ajax
|
||||
}
|
||||
}).$mount('#app')
|
||||
|
||||
console.log("Vue started")
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
<div class="field is-grouped is-right-floating is-bottom-floating">
|
||||
<p class="control">
|
||||
<a class="button is-primary is-medium" v-if="remaining" v-on:click="go_back">Back</a>
|
||||
<a class="button is-primary is-medium" v-if="remaining && !is_launcher" v-on:click="go_back">Back</a>
|
||||
<a class="button is-primary is-medium" v-if="is_launcher" v-on:click="exit">Exit</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -60,6 +60,8 @@ export default {
|
||||
}
|
||||
|
||||
this.$root.stream_ajax(targetUrl, function (line) {
|
||||
// On progress line received from server
|
||||
|
||||
if (line.hasOwnProperty('Status')) {
|
||||
that.progress_message = line.Status[0]
|
||||
that.progress = line.Status[1] * 100
|
||||
@ -70,14 +72,12 @@ export default {
|
||||
}
|
||||
|
||||
if (line.hasOwnProperty('Error')) {
|
||||
if (app.metadata.is_launcher) {
|
||||
app.exit()
|
||||
} else {
|
||||
that.failed_with_error = true
|
||||
that.$router.replace({ name: 'showerr', params: { msg: line.Error } })
|
||||
}
|
||||
that.failed_with_error = true
|
||||
that.$router.replace({ name: 'showerr', params: { msg: line.Error } })
|
||||
}
|
||||
}, function (e) {
|
||||
// On request completed
|
||||
|
||||
if (that.is_updater_update) {
|
||||
// Continue with what we were doing
|
||||
if (app.metadata.is_launcher) {
|
||||
|
Loading…
Reference in New Issue
Block a user