Skip to content

Commit d52cca2

Browse files
committed
background_jobs: Remove unused UpdateCrateIndex job
This has been replaced by the two `SyncToGit/SparseIndex` jobs
1 parent 9f6809a commit d52cca2

File tree

3 files changed

+1
-40
lines changed

3 files changed

+1
-40
lines changed

src/background_jobs.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub enum Job {
2020
SquashIndex,
2121
SyncToGitIndex(SyncToIndexJob),
2222
SyncToSparseIndex(SyncToIndexJob),
23-
UpdateCrateIndex(UpdateCrateIndexJob),
2423
UpdateDownloads,
2524
}
2625

@@ -46,7 +45,6 @@ impl Job {
4645
const SQUASH_INDEX: &str = "squash_index";
4746
const SYNC_TO_GIT_INDEX: &str = "sync_to_git_index";
4847
const SYNC_TO_SPARSE_INDEX: &str = "sync_to_sparse_index";
49-
const UPDATE_CRATE_INDEX: &str = "update_crate_index";
5048
const UPDATE_DOWNLOADS: &str = "update_downloads";
5149

5250
pub fn enqueue_sync_to_index<T: ToString>(
@@ -121,10 +119,6 @@ impl Job {
121119
})
122120
}
123121

124-
pub fn update_crate_index(crate_name: String) -> Self {
125-
Self::UpdateCrateIndex(UpdateCrateIndexJob { crate_name })
126-
}
127-
128122
pub fn update_downloads() -> Self {
129123
Self::UpdateDownloads
130124
}
@@ -138,7 +132,6 @@ impl Job {
138132
Job::SquashIndex => Self::SQUASH_INDEX,
139133
Job::SyncToGitIndex(_) => Self::SYNC_TO_GIT_INDEX,
140134
Job::SyncToSparseIndex(_) => Self::SYNC_TO_SPARSE_INDEX,
141-
Job::UpdateCrateIndex(_) => Self::UPDATE_CRATE_INDEX,
142135
Job::UpdateDownloads => Self::UPDATE_DOWNLOADS,
143136
}
144137
}
@@ -152,7 +145,6 @@ impl Job {
152145
Job::SquashIndex => Ok(serde_json::Value::Null),
153146
Job::SyncToGitIndex(inner) => serde_json::to_value(inner),
154147
Job::SyncToSparseIndex(inner) => serde_json::to_value(inner),
155-
Job::UpdateCrateIndex(inner) => serde_json::to_value(inner),
156148
Job::UpdateDownloads => Ok(serde_json::Value::Null),
157149
}
158150
}
@@ -180,7 +172,6 @@ impl Job {
180172
Self::SQUASH_INDEX => Job::SquashIndex,
181173
Self::SYNC_TO_GIT_INDEX => Job::SyncToGitIndex(from_value(value)?),
182174
Self::SYNC_TO_SPARSE_INDEX => Job::SyncToSparseIndex(from_value(value)?),
183-
Self::UPDATE_CRATE_INDEX => Job::UpdateCrateIndex(from_value(value)?),
184175
Self::UPDATE_DOWNLOADS => Job::UpdateDownloads,
185176
job_type => Err(PerformError::from(format!("Unknown job type {job_type}")))?,
186177
})
@@ -201,7 +192,6 @@ impl Job {
201192
}
202193
Job::DumpDb(args) => worker::perform_dump_db(env, args.database_url, args.target_name),
203194
Job::SquashIndex => worker::perform_index_squash(env),
204-
Job::UpdateCrateIndex(args) => worker::perform_index_sync_to_http(env, args.crate_name),
205195
Job::NormalizeIndex(args) => worker::perform_normalize_index(env, args),
206196
Job::RenderAndUploadReadme(args) => worker::perform_render_and_upload_readme(
207197
conn,

src/worker/git.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,6 @@ use std::fs::{self, File};
99
use std::io::{BufRead, BufReader, ErrorKind, Write};
1010
use std::process::Command;
1111

12-
#[instrument(skip(env))]
13-
pub fn perform_index_sync_to_http(
14-
env: &Environment,
15-
crate_name: String,
16-
) -> Result<(), PerformError> {
17-
info!("Syncing git index to HTTP-based index");
18-
19-
let repo = env.lock_index()?;
20-
let dst = repo.index_file(&crate_name);
21-
22-
let contents = match fs::read_to_string(dst) {
23-
Ok(contents) => Some(contents),
24-
Err(e) if e.kind() == ErrorKind::NotFound => None,
25-
Err(e) => return Err(e.into()),
26-
};
27-
28-
env.uploader
29-
.sync_index(env.http_client(), &crate_name, contents)?;
30-
31-
if let Some(cloudfront) = env.cloudfront() {
32-
let path = Repository::relative_index_file_for_url(&crate_name);
33-
info!(%path, "Invalidating index file on CloudFront");
34-
cloudfront.invalidate(env.http_client(), &path)?;
35-
}
36-
37-
Ok(())
38-
}
39-
4012
/// Regenerates or removes an index file for a single crate
4113
#[instrument(skip_all, fields(krate.name = ?krate))]
4214
pub fn sync_to_git_index(

src/worker/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ mod update_downloads;
1313
pub(crate) use daily_db_maintenance::perform_daily_db_maintenance;
1414
pub(crate) use dump_db::perform_dump_db;
1515
pub(crate) use git::{
16-
perform_index_squash, perform_index_sync_to_http, perform_normalize_index, sync_to_git_index,
17-
sync_to_sparse_index,
16+
perform_index_squash, perform_normalize_index, sync_to_git_index, sync_to_sparse_index,
1817
};
1918
pub(crate) use readmes::perform_render_and_upload_readme;
2019
pub(crate) use update_downloads::perform_update_downloads;

0 commit comments

Comments
 (0)