fix(profile): handle missing chain files without breaking rollback

This commit is contained in:
wonfen
2026-07-19 08:44:24 +08:00
parent 6e9288437f
commit 50d828d0d7
4 changed files with 51 additions and 16 deletions
+12
View File
@@ -404,6 +404,18 @@ pub async fn read_profile_file(index: String) -> CmdResult<String> {
..Default::default()
}
};
if let Some(file) = item.file.as_ref() {
let path = dirs::app_profiles_dir().stringify_err()?.join(file.as_str());
match tokio::fs::try_exists(&path).await {
Ok(true) => {}
Ok(false) => return Ok(String::new()),
Err(err) => {
return Err(format!("failed to check profile file \"{}\": {err}", path.display()).into());
}
}
}
let data = item.read_file().await.stringify_err()?;
Ok(data)
}