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-12-03 17:20:32 +08:00
parent 03ff4f846c
commit 72e7201abc
8 changed files with 50 additions and 45 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?;