Skip to content

armgit / kanzo

Public Imported from GitHub
0

Self-hosted, sharable kanban for humans and agents. One 4.7 MB binary, 5 MB of RAM, 10 to 60 tokens per agent reply, starts in 3 ms, zero setup.

Turn a race on project creation into a clear error

emanuele-em40aed0a88f8a
diff --git a/src/store.rs b/src/store.rs
index f03df82..7733268 100644
--- a/src/store.rs
+++ b/src/store.rs
@@ -292,7 +292,16 @@ impl Store {
{
return Err(Error::Invalid(format!("repo {r} is already linked to project {}", other.slug)));
}
- self.conn.execute("INSERT INTO projects (slug, name, repo) VALUES (?1, ?2, ?3)", params![slug, name, repo])?;
+ match self
+ .conn
+ .execute("INSERT INTO projects (slug, name, repo) VALUES (?1, ?2, ?3)", params![slug, name, repo])
+ {
+ // Someone created the same project between our check and the insert.
+ Err(rusqlite::Error::SqliteFailure(e, _)) if e.code == rusqlite::ErrorCode::ConstraintViolation => {
+ return Err(Error::Invalid(format!("project {slug} or its repo already exists")));
+ }
+ other => other?,
+ };
self.find_project(&slug)
}