feat(config-sync): add per-instance config profiles
This commit is contained in:
1 parent
8f16931502
commit
69549b7152
8 files changed
+791
No files matched your search
@@ -46,6 +46,8 @@ pub enum LaunchError {
|
||||
},
|
||||
#[error("{0}")]
|
||||
Auth(String),
|
||||
#[error("Config sync error: {0}")]
|
||||
ConfigSync(#[from] crate::instance::config_sync::ConfigSyncError),
|
||||
}
|
||||
|
||||
fn build_game_args(
|
||||
@@ -621,6 +623,13 @@ pub async fn launch(
|
||||
invocation.game_args.len(),
|
||||
invocation.main_class
|
||||
);
|
||||
let config_sync_profile = config.config_sync_profile.clone();
|
||||
let config_sync_lock = crate::instance::config_sync::prepare(
|
||||
config_sync_profile.as_deref(),
|
||||
meta_dir,
|
||||
&invocation.working_dir,
|
||||
)?;
|
||||
let config_sync_active = config_sync_lock.is_some();
|
||||
|
||||
let (kill_tx, kill_rx) = tokio::sync::oneshot::channel::<()>();
|
||||
crate::running::register_kill(&name, kill_tx);
|
||||
@@ -682,6 +691,7 @@ pub async fn launch(
|
||||
let name_for_task = name.clone();
|
||||
let instances_dir_owned = instances_dir.to_path_buf();
|
||||
let meta_dir_owned = meta_dir.to_path_buf();
|
||||
let minecraft_dir_owned = invocation.working_dir.clone();
|
||||
|
||||
// spawn a background task to babysit the child process: capture stdout/stderr
|
||||
// into both the TUI log viewer and a timestamped log file on disk
|
||||
@@ -783,6 +793,17 @@ pub async fn launch(
|
||||
let _ = parser_task.await;
|
||||
tracing::info!("[{}] Exited with code {:?}", name_for_task, code);
|
||||
|
||||
if config_sync_active {
|
||||
if let Err(e) = crate::instance::config_sync::finish(
|
||||
config_sync_profile.as_deref(),
|
||||
&meta_dir_owned,
|
||||
&minecraft_dir_owned,
|
||||
) {
|
||||
tracing::warn!("Failed to sync config for '{}': {}", name_for_task, e);
|
||||
}
|
||||
}
|
||||
drop(config_sync_lock);
|
||||
|
||||
if code == Some(0) || killed_by_user {
|
||||
crate::running::remove(&name_for_task);
|
||||
tracing::debug!(
|
||||
@@ -1015,6 +1036,7 @@ mod tests {
|
||||
memory_min: None,
|
||||
jvm_args: Vec::new(),
|
||||
resolution: None,
|
||||
config_sync_profile: None,
|
||||
};
|
||||
|
||||
let result =
|
||||
@@ -1062,6 +1084,7 @@ mod tests {
|
||||
memory_min: None,
|
||||
jvm_args: Vec::new(),
|
||||
resolution: None,
|
||||
config_sync_profile: None,
|
||||
};
|
||||
|
||||
let result = migrate_legacy_loader_profile_if_needed(
|
||||
|
||||
Reference in new issue
Block a user