jlcodes99/cockpit-tools · warning
[DataTransfer] 配置导入失败后回滚应用自启动状态失败: {}
Error message
[DataTransfer] 配置导入失败后回滚应用自启动状态失败: {} What it means
During user-config import (data_transfer_apply_user_config), if the import itself fails while the app auto-launch setting had already been changed, the code attempts to roll back the auto-launch setting to its previous value. This error is logged when that rollback also fails, meaning the system is left with an auto-launch state that differs from the user's original configuration.
Source
Thrown at src-tauri/src/commands/data_transfer.rs:138
|| current.report_port != next_config.report_port
|| current.report_token != next_config.report_token;
language_changed = current.language != next_config.language;
#[cfg(target_os = "macos")]
{
hide_dock_icon_changed = current.hide_dock_icon != next_config.hide_dock_icon;
tray_icon_style_changed = current.tray_icon_style != next_config.tray_icon_style;
}
*current = next_config.clone();
Ok(())
});
let next_config = match patch_result {
Ok(config) => config,
Err(error) => {
if app_auto_launch_changed {
if let Err(rollback_error) =
apply_app_auto_launch_enabled(&app, previous_auto_launch)
{
modules::logger::log_error(&format!(
"[DataTransfer] 配置导入失败后回滚应用自启动状态失败: {}",
rollback_error
));
}
}
return Err(error);
}
};
if let Err(err) = modules::floating_card_window::apply_floating_card_always_on_top(&app) {
modules::logger::log_warn(&format!("[DataTransfer] 应用悬浮卡片置顶状态失败: {}", err));
}
#[cfg(target_os = "macos")]
if hide_dock_icon_changed {
crate::apply_macos_activation_policy(&app);
}
View on GitHub (pinned to 1ed8b77992)
Solutions
- Manually re-check and reset the app's 'launch at startup' toggle in settings to restore the previous state
- Re-run the config import after fixing the underlying import failure (the wrapped `error` in the returned Err tells you why import failed)
- Check OS autostart configuration (systemd user services / autostart .desktop file / registry) for permission problems
- Avoid importing configs that toggle auto-launch across machines with different OS environments without verifying autostart works
Example fix
// before
if let Err(rollback_error) = apply_app_auto_launch_enabled(&app, previous_auto_launch) {
modules::logger::log_error(&format!("[DataTransfer] 配置导入失败后回滚应用自启动状态失败: {}", rollback_error));
}
return Err(error);
// after
if let Err(rollback_error) = apply_app_auto_launch_enabled(&app, previous_auto_launch) {
modules::logger::log_error(&format!("[DataTransfer] 配置导入失败后回滚应用自启动状态失败: {}", rollback_error));
// surface both failures so the user knows the auto-launch state may be inconsistent
return Err(format!("{};此外,回滚应用自启动状态失败: {}", error, rollback_error));
}
return Err(error); Defensive patterns
Strategy: try-catch
Validate before calling
// validate config and autostart capability BEFORE applying anything
if let Err(e) = validate_user_config(&imported_config) {
return Err(format!("配置无效,未做任何修改: {}", e));
}
if app_auto_launch_changed && !auto_launch_supported() {
return Err("当前环境不支持自启动设置,已取消导入".to_string());
} Try / catch
// apply, and on failure roll back; if rollback also fails, surface BOTH errors
match apply_user_config(&config).await {
Ok(v) => Ok(v),
Err(error) => {
if app_auto_launch_changed {
if let Err(rb) = apply_app_auto_launch_enabled(&app, previous_auto_launch) {
return Err(format!("{};且回滚自启动状态失败,请手动检查自启动设置: {}", error, rb));
}
}
Err(error)
}
} Prevention
- Validate the imported config before applying any side effects
- Apply auto-launch only after the main config import succeeds (order side effects last)
- Verify autostart works on the target platform (Flatpak/sandboxed environments often break it)
- After a failed import, always re-check the auto-launch toggle
When it happens
Trigger: apply_user_config returned Err while app_auto_launch_changed was true, and the compensating apply_app_auto_launch_enabled(&app, previous_auto_launch) call also returned Err — e.g. OS-level autostart registration failed (missing desktop entry / registry write failure / permissions).
Common situations: Restoring a config on a platform where autostart registration is broken (Linux desktop-entry issues, sandboxed/Flatpak environments); read-only or permission-restricted autostart location; the import failed due to a malformed config file while autostart had already been toggled off.
Related errors
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/7b26914daac96c28.
Report an issue: GitHub.