Skip to content

Commit d654abb

Browse files
arlosiTurbo87
authored andcommitted
admin/delete_crate: Use sync_to_git/sparse_index() jobs if FEATURE_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.
1 parent e0475ad commit d654abb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/admin/delete_crate.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::background_jobs::Job;
12
use crate::{admin::dialoguer, config, db, models::Crate, schema::crates};
23

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

57-
uploader.delete_index(&client, &krate.name).unwrap();
58+
if dotenv::var("FEATURE_INDEX_SYNC").is_ok() {
59+
Job::sync_to_git_index(&krate.name).enqueue(conn).unwrap();
60+
Job::sync_to_sparse_index(&krate.name)
61+
.enqueue(conn)
62+
.unwrap();
63+
} else {
64+
uploader.delete_index(&client, &krate.name).unwrap();
65+
}
5866
}

0 commit comments

Comments
 (0)