Skip to content

Commit

Permalink
Make invalidated logic clearer
Browse files Browse the repository at this point in the history
Created using spr 1.3.4
  • Loading branch information
sunshowers committed Oct 5, 2023
1 parent b456f42 commit edd6b16
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions crdb-seed/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,34 @@ async fn ensure_seed_tarball_exists(
let mut desired_seed_tar = base_seed_dir.join(digest_unique_to_schema());
desired_seed_tar.set_extension("tar");

let invalidated = if desired_seed_tar.exists() {
if !should_invalidate {
let invalidated = match (desired_seed_tar.exists(), should_invalidate) {
(true, true) => {
slog::info!(
log,
"CRDB_SEED_INVALIDATE=1 set in the environment, \
invalidating seed tarball: `{}`",
desired_seed_tar,
);
std::fs::remove_file(&desired_seed_tar)
.context("failed to remove seed tarball")?;
true
}
(true, false) => {
return Ok((desired_seed_tar, SeedTarballStatus::Existing));
}
slog::info!(
log,
"CRDB_SEED_INVALIDATE=1 set in the environment, \
invalidating seed tarball: `{}`",
desired_seed_tar,
);
std::fs::remove_file(&desired_seed_tar)
.context("failed to remove seed tarball")?;
true
} else {
if should_invalidate {
(false, true) => {
slog::info!(
log,
"CRDB_SEED_INVALIDATE=1 set in the environment, \
but seed tarball does not exist: `{}`",
desired_seed_tar,
);
false
}
(false, false) => {
// The tarball doesn't exist.
false
}
false
};

// The tarball didn't exist when we started, so try to create it.
Expand Down

0 comments on commit edd6b16

Please sign in to comment.