From 45ec3fb3a48423334226be69ce96ae04b0bf9cb2 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 30 Sep 2024 13:18:32 +0200 Subject: [PATCH] controllers/version/metadata: Fix `yanked` usage This was using the previous `yanked` state for the admin log message, instead of the new state. --- src/controllers/version/metadata.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/controllers/version/metadata.rs b/src/controllers/version/metadata.rs index 9f18c6712f5..41e24edd06e 100644 --- a/src/controllers/version/metadata.rs +++ b/src/controllers/version/metadata.rs @@ -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} {}@{}", user.gh_login, krate.name, version.num @@ -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( @@ -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