Skip to content

Commit

Permalink
admin/delete_crate: Use sync_to_git/sparse_index() jobs if `FEATURE…
Browse files Browse the repository at this point in the history
…_INDEX_SYNC` env var is set

This ensures that the crate is deleted from both the git index and the sparse index, and that the CloudFront invalidation is correctly sent out.
  • Loading branch information
arlosi authored and Turbo87 committed Apr 21, 2023
1 parent 2abb56a commit 9970279
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/admin/delete_crate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::background_jobs::Job;
use crate::{admin::dialoguer, config, db, models::Crate, schema::crates};

use diesel::prelude::*;
Expand Down Expand Up @@ -54,5 +55,12 @@ fn delete(opts: Opts, conn: &mut PgConnection) {
panic!("aborting transaction");
}

uploader.delete_index(&client, &krate.name).unwrap();
if dotenv::var("FEATURE_INDEX_SYNC").is_ok() {
Job::sync_to_git_index(&krate.name).enqueue(conn).unwrap();
Job::sync_to_sparse_index(&krate.name)
.enqueue(conn)
.unwrap();
} else {
uploader.delete_index(&client, &krate.name).unwrap();
}
}

0 comments on commit 9970279

Please sign in to comment.