Skip to content

Commit

Permalink
controllers/version/metadata: Fix yanked usage
Browse files Browse the repository at this point in the history
This was using the previous `yanked` state for the admin log message, instead of the new state.
  • Loading branch information
Turbo87 committed Sep 30, 2024
1 parent cccdd74 commit 45ec3fb
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/controllers/version/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,11 @@ pub fn perform_version_yank_update(
let user = auth.user();
let owners = krate.owners(conn)?;

let yanked = yanked.unwrap_or(version.yanked);

if Handle::current().block_on(user.rights(state, &owners))? < Rights::Publish {
if user.is_admin {
let action = if version.yanked {
"yanking"
} else {
"unyanking"
};
let action = if yanked { "yanking" } else { "unyanking" };
warn!(
"Admin {} is {action} {}@{}",

Check warning on line 196 in src/controllers/version/metadata.rs

View check run for this annotation

Codecov / codecov/patch

src/controllers/version/metadata.rs#L196

Added line #L196 was not covered by tests
user.gh_login, krate.name, version.num
Expand All @@ -206,7 +204,6 @@ pub fn perform_version_yank_update(
}
}

let yanked = yanked.unwrap_or(version.yanked);
// Check if the yanked state or yank message has changed and update if necessary
let updated_cnt = diesel::update(
versions::table.find(version.id).filter(
Expand All @@ -230,7 +227,7 @@ pub fn perform_version_yank_update(
version.yanked = yanked;
version.yank_message = yank_message;

let action = if version.yanked {
let action = if yanked {
VersionAction::Yank
} else {
VersionAction::Unyank
Expand Down

0 comments on commit 45ec3fb

Please sign in to comment.