Skip to content

Commit 884995a

Browse files
committed
Drop database connections to avoid reentrancy in tests
This fixes the remaining tests but it may be desirable to refactor things to reuse an existing connection rather than drop and obtain a new one.
1 parent 3506894 commit 884995a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/controllers/github/secret_scanning.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ fn alert_revoke_token(
182182
.set(api_tokens::revoked.eq(true))
183183
.execute(&*conn)?;
184184

185+
drop(conn);
186+
185187
warn!(
186188
token_id = %token.id, user_id = %token.user_id,
187189
"Active API token received and revoked (true positive)",

src/controllers/krate/publish.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub fn publish(req: &mut ConduitRequest) -> EndpointResult {
7272
.first::<Crate>(&*conn)
7373
.optional()?;
7474

75+
drop(conn);
76+
7577
let endpoint_scope = match existing_crate {
7678
Some(_) => EndpointScope::PublishUpdate,
7779
None => EndpointScope::PublishNew,
@@ -85,6 +87,7 @@ pub fn publish(req: &mut ConduitRequest) -> EndpointResult {
8587
let api_token_id = auth.api_token_id();
8688
let user = auth.user();
8789

90+
let conn = app.primary_database.get()?;
8891
let verified_email_address = user.verified_email(&conn)?;
8992
let verified_email_address = verified_email_address.ok_or_else(|| {
9093
cargo_err(&format!(

0 commit comments

Comments
 (0)