refactor(draft): type async publication conflicts

Return typed conflicts for async Draft edits. Release the lock and edit permit before converting the error, and exercise overlapping updates.
This commit is contained in:
Tunglies
2026-11-30 18:13:47 +08:00
parent 7b43bac198
commit 1c7bc3200b
8 changed files with 46 additions and 41 deletions
+2 -2
View File
@@ -159,7 +159,7 @@ pub async fn delete_profile(index: std::string::String) -> CmdResult {
let profiles = Config::profiles().await;
let result = profiles
.with_data_modify(|mut candidate| async move {
.with_data_modify::<_, _, _, anyhow::Error>(|mut candidate| async move {
let original = candidate.clone();
let (should_update, plan) = candidate.plan_delete_item(&index)?;
let guard = if should_update {
@@ -584,7 +584,7 @@ mod tests {
profiles
.with_data_modify(|mut committed| async move {
committed.items.get_or_insert_with(Vec::new).push(profile("new"));
Ok((committed, ()))
Ok::<_, clash_verge_draft::DraftConflict>((committed, ()))
})
.await?;