Skip to content

Commit df3ca31

Browse files
committed
controllers/krate/publish: Use match to simplify NewCrate::create() call
1 parent 1597fb8 commit df3ca31

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/controllers/krate/publish.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,10 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
157157
let krate = conn.transaction(|conn| {
158158
// To avoid race conditions, we try to insert
159159
// first so we know whether to add an owner
160-
if let Some(krate) = persist.create(conn, user.id).optional()? {
161-
return Ok(krate);
160+
match persist.create(conn, user.id).optional()? {
161+
Some(krate) => Ok(krate),
162+
None => persist.update(conn),
162163
}
163-
164-
persist.update(conn)
165164
})?;
166165

167166
let owners = krate.owners(conn)?;

0 commit comments

Comments
 (0)