Skip to content

Commit 0e7a0b3

Browse files
committed
controllers/krate/publish: Remove redundant inner transaction
1 parent df3ca31 commit 0e7a0b3

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/controllers/krate/publish.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,12 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
154154
return Err(cargo_err("cannot upload a crate with a reserved name"));
155155
}
156156

157-
let krate = conn.transaction(|conn| {
158-
// To avoid race conditions, we try to insert
159-
// first so we know whether to add an owner
160-
match persist.create(conn, user.id).optional()? {
161-
Some(krate) => Ok(krate),
162-
None => persist.update(conn),
163-
}
164-
})?;
157+
// To avoid race conditions, we try to insert
158+
// first so we know whether to add an owner
159+
let krate = match persist.create(conn, user.id).optional()? {
160+
Some(krate) => krate,
161+
None => persist.update(conn)?,
162+
};
165163

166164
let owners = krate.owners(conn)?;
167165
if user.rights(&app, &owners)? < Rights::Publish {

0 commit comments

Comments
 (0)