Skip to content

background_jobs: Adjust perform() to work on &self #7395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/background_jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl Job {
}

pub(super) fn perform(
self,
&self,
env: &Option<Environment>,
state: PerformState<'_>,
) -> Result<(), PerformError> {
Expand All @@ -253,7 +253,9 @@ impl Job {
Job::DailyDbMaintenance => {
worker::perform_daily_db_maintenance(&mut *fresh_connection(pool)?)
}
Job::DumpDb(args) => worker::perform_dump_db(env, args.database_url, args.target_name),
Job::DumpDb(args) => {
worker::perform_dump_db(env, &args.database_url, &args.target_name)
}
Job::SquashIndex => worker::perform_index_squash(env),
Job::NormalizeIndex(args) => worker::perform_normalize_index(env, args),
Job::RenderAndUploadReadme(args) => worker::perform_render_and_upload_readme(
Expand Down
10 changes: 5 additions & 5 deletions src/worker/dump_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use crate::swirl::PerformError;
/// tarball and upload to S3.
pub fn perform_dump_db(
env: &Environment,
database_url: String,
target_name: String,
database_url: &str,
target_name: &str,
) -> Result<(), PerformError> {
let directory = DumpDirectory::create()?;

info!(path = ?directory.export_dir, "Begin exporting database");
directory.populate(&database_url)?;
directory.populate(database_url)?;

info!(path = ?directory.export_dir, "Creating tarball");
let tarball = DumpTarball::create(&directory.export_dir)?;
Expand All @@ -33,11 +33,11 @@ pub fn perform_dump_db(

let storage = Storage::from_environment();

rt.block_on(storage.upload_db_dump(&target_name, &tarball.tarball_path))?;
rt.block_on(storage.upload_db_dump(target_name, &tarball.tarball_path))?;
info!("Database dump tarball uploaded");

info!("Invalidating CDN caches");
invalidate_caches(env, &target_name);
invalidate_caches(env, target_name);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/worker/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn perform_index_squash(env: &Environment) -> Result<(), PerformError> {

pub fn perform_normalize_index(
env: &Environment,
args: NormalizeIndexJob,
args: &NormalizeIndexJob,
) -> Result<(), PerformError> {
info!("Normalizing the index");

Expand Down