mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-25 14:55:41 +01:00
feat(install): add recovery mode ...
... when metadata is corrupted, recovery mode will be activated
This commit is contained in:
parent
109322836b
commit
0d4022d348
@ -84,6 +84,8 @@ pub struct AuthenticationConfig {
|
|||||||
pub struct BaseAttributes {
|
pub struct BaseAttributes {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub target_url: String,
|
pub target_url: String,
|
||||||
|
#[serde(default)]
|
||||||
|
pub recovery: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BaseAttributes {
|
impl BaseAttributes {
|
||||||
|
@ -459,6 +459,23 @@ impl InstallerFramework {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The special recovery mode for the Installer Framework.
|
||||||
|
pub fn new_recovery_mode(attrs: BaseAttributes, install_path: &Path) -> Self {
|
||||||
|
InstallerFramework {
|
||||||
|
base_attributes: BaseAttributes {
|
||||||
|
recovery: true,
|
||||||
|
..attrs
|
||||||
|
},
|
||||||
|
config: None,
|
||||||
|
database: InstallationDatabase::new(),
|
||||||
|
install_path: Some(install_path.to_path_buf()),
|
||||||
|
preexisting_install: true,
|
||||||
|
is_launcher: false,
|
||||||
|
burn_after_exit: false,
|
||||||
|
launcher_path: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a new instance of the Installer Framework with a specified Config, managing
|
/// Creates a new instance of the Installer Framework with a specified Config, managing
|
||||||
/// a pre-existing installation.
|
/// a pre-existing installation.
|
||||||
pub fn new_with_db(attrs: BaseAttributes, install_path: &Path) -> Result<Self, String> {
|
pub fn new_with_db(attrs: BaseAttributes, install_path: &Path) -> Result<Self, String> {
|
||||||
|
@ -127,7 +127,11 @@ fn main() {
|
|||||||
let metadata_file = current_path.join("metadata.json");
|
let metadata_file = current_path.join("metadata.json");
|
||||||
let mut framework = if metadata_file.exists() {
|
let mut framework = if metadata_file.exists() {
|
||||||
info!("Using pre-existing metadata file: {:?}", metadata_file);
|
info!("Using pre-existing metadata file: {:?}", metadata_file);
|
||||||
InstallerFramework::new_with_db(config, current_path).log_expect("Unable to parse metadata")
|
InstallerFramework::new_with_db(config.clone(), current_path).unwrap_or_else(|e| {
|
||||||
|
error!("Failed to load metadata: {:?}", e);
|
||||||
|
warn!("Entering recovery mode");
|
||||||
|
InstallerFramework::new_recovery_mode(config, current_path)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
info!("Starting fresh install");
|
info!("Starting fresh install");
|
||||||
fresh_install = true;
|
fresh_install = true;
|
||||||
|
@ -10,6 +10,7 @@ let maintenance = false
|
|||||||
let launcher = false
|
let launcher = false
|
||||||
let fileExists = false
|
let fileExists = false
|
||||||
let darkMode = false
|
let darkMode = false
|
||||||
|
let recoveryMode = false
|
||||||
|
|
||||||
function progressSimulation (res) {
|
function progressSimulation (res) {
|
||||||
if (showError) {
|
if (showError) {
|
||||||
@ -71,7 +72,7 @@ function returnConfig (res) {
|
|||||||
app.get('/api/attrs', (req, res) => {
|
app.get('/api/attrs', (req, res) => {
|
||||||
console.log('-- Get attrs')
|
console.log('-- Get attrs')
|
||||||
res.send(
|
res.send(
|
||||||
{ name: 'yuzu', target_url: 'https://raw.githubusercontent.com/j-selby/test-installer/master/config.linux.v2.toml' }
|
{ name: 'yuzu', recovery: recoveryMode, target_url: 'https://raw.githubusercontent.com/j-selby/test-installer/master/config.linux.v2.toml' }
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -161,6 +162,10 @@ process.argv.forEach((val, index) => {
|
|||||||
showError = true
|
showError = true
|
||||||
console.log('Simulating errors')
|
console.log('Simulating errors')
|
||||||
break
|
break
|
||||||
|
case 'recovery':
|
||||||
|
recoveryMode = true
|
||||||
|
console.log('Simulating recovery mode')
|
||||||
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
"repair": "Repair",
|
"repair": "Repair",
|
||||||
"uninstall":"Uninstall",
|
"uninstall":"Uninstall",
|
||||||
"view_local_files": "View local files",
|
"view_local_files": "View local files",
|
||||||
|
"prompt_recover": "Installer data for {name} is corrupted.<br>A repair is required to restore the installation.",
|
||||||
"prompt":"Are you sure you want to uninstall {name}?",
|
"prompt":"Are you sure you want to uninstall {name}?",
|
||||||
"prompt_confirm":"Uninstall {name}"
|
"prompt_confirm":"Uninstall {name}"
|
||||||
},
|
},
|
||||||
|
@ -38,7 +38,22 @@ export default {
|
|||||||
data: function () {
|
data: function () {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
|
mounted: function () {
|
||||||
|
if (this.$root.$data.attrs.recovery) {
|
||||||
|
this.recovery()
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
recovery: function () {
|
||||||
|
this.$buefy.dialog.alert({
|
||||||
|
title: this.$t('modify.repair'),
|
||||||
|
message: this.$t('modify.prompt_recover', { name: this.$root.$data.attrs.name }),
|
||||||
|
confirmText: this.$t('continue'),
|
||||||
|
type: 'is-danger',
|
||||||
|
hasIcon: true,
|
||||||
|
onConfirm: this.repair_packages
|
||||||
|
})
|
||||||
|
},
|
||||||
update: function () {
|
update: function () {
|
||||||
this.$router.push('/install/update/false')
|
this.$router.push('/install/update/false')
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user