Skip to content

Commit 46d96d3

Browse files
committed
worker::git: Change version argument of yank() to String
We only need the `num` field, so there is no need for us to save the full `Version` in the task payload
1 parent 372601e commit 46d96d3

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/controllers/version/yank.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn modify_yank(req: &mut dyn RequestExt, yanked: bool) -> EndpointResult {
6161

6262
insert_version_owner_action(&conn, version.id, user.id, api_token_id, action)?;
6363

64-
worker::yank(krate.name, version, yanked).enqueue(&conn)?;
64+
worker::yank(krate.name, version.num, yanked).enqueue(&conn)?;
6565

6666
ok_true()
6767
}

src/worker/git.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::background_jobs::Environment;
22
use crate::git::{Crate, Credentials};
3-
use crate::models::Version;
43
use chrono::Utc;
54
use std::fs::{self, OpenOptions};
65
use std::io::prelude::*;
@@ -32,7 +31,7 @@ pub fn add_crate(env: &Environment, krate: Crate) -> Result<(), PerformError> {
3231
pub fn yank(
3332
env: &Environment,
3433
krate: String,
35-
version: Version,
34+
version_num: String,
3635
yanked: bool,
3736
) -> Result<(), PerformError> {
3837
let repo = env.lock_index()?;
@@ -44,7 +43,7 @@ pub fn yank(
4443
.map(|line| {
4544
let mut git_crate = serde_json::from_str::<Crate>(line)
4645
.map_err(|_| format!("couldn't decode: `{}`", line))?;
47-
if git_crate.name != krate || git_crate.vers != version.num {
46+
if git_crate.name != krate || git_crate.vers != version_num {
4847
return Ok(line.to_string());
4948
}
5049
git_crate.yanked = Some(yanked);
@@ -58,7 +57,7 @@ pub fn yank(
5857
"{} crate `{}#{}`",
5958
if yanked { "Yanking" } else { "Unyanking" },
6059
krate,
61-
version.num
60+
version_num
6261
);
6362

6463
repo.commit_and_push(&message, &dst)?;

0 commit comments

Comments
 (0)