diff --git a/src/commands/prune.rs b/src/commands/prune.rs index 2dec48d84..9f93746ec 100644 --- a/src/commands/prune.rs +++ b/src/commands/prune.rs @@ -40,9 +40,13 @@ impl PruneCmd { print_stats(&prune_plan.stats); - if config.global.dry_run { + let dry_run = config.global.dry_run; + if dry_run && config.global.dry_run_warmup { repo.warm_up(prune_plan.repack_packs().into_iter())?; - } else { + } else if !config.global.dry_run_warmup { + info!("Ignoring --dry-run-warmup works only in combination with --dry-run"); + } + if !dry_run { repo.prune(&self.opts, prune_plan)?; } diff --git a/src/commands/restore.rs b/src/commands/restore.rs index 6478303e9..64efba43e 100644 --- a/src/commands/restore.rs +++ b/src/commands/restore.rs @@ -94,15 +94,19 @@ impl RestoreCmd { info!("all file contents are fine."); } - if dry_run { + if dry_run && config.global.dry_run_warmup { repo.warm_up(restore_infos.to_packs().into_iter())?; - } else { + } else if !dry_run && !config.global.dry_run_warmup { // save some memory let repo = repo.drop_data_from_index(); let ls = repo.ls(&node, &ls_opts)?; repo.restore(restore_infos, &self.opts, ls, &dest)?; println!("restore done."); + } else { + info!( + "--dry-run is without warmup, --dry-run --dry-run-warmup also issues the warmup script." + ); } Ok(()) diff --git a/src/config.rs b/src/config.rs index bd39cdba1..c7e7f256e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -176,6 +176,11 @@ pub struct GlobalOptions { #[merge(strategy=conflate::bool::overwrite_false)] pub dry_run: bool, + /// Additional to dry run, but still issue warm-up command if configured + #[clap(long, global = true, env = "RUSTIC_DRY_RUN_WARMUP")] + #[merge(strategy=conflate::bool::overwrite_false)] + pub dry_run_warmup: bool, + /// Check if index matches pack files and read pack headers if necessary #[clap(long, global = true, env = "RUSTIC_CHECK_INDEX")] #[merge(strategy=conflate::bool::overwrite_false)] diff --git a/src/snapshots/rustic_rs__config__tests__default_config_display_passes.snap b/src/snapshots/rustic_rs__config__tests__default_config_display_passes.snap index 1cfcddfd1..62ba1ec2f 100644 --- a/src/snapshots/rustic_rs__config__tests__default_config_display_passes.snap +++ b/src/snapshots/rustic_rs__config__tests__default_config_display_passes.snap @@ -5,6 +5,7 @@ expression: config [global] use-profiles = [] dry-run = false +dry-run-warmup = false check-index = false no-progress = false diff --git a/src/snapshots/rustic_rs__config__tests__default_config_passes.snap b/src/snapshots/rustic_rs__config__tests__default_config_passes.snap index c1c2a02dc..e3791f75e 100644 --- a/src/snapshots/rustic_rs__config__tests__default_config_passes.snap +++ b/src/snapshots/rustic_rs__config__tests__default_config_passes.snap @@ -7,6 +7,7 @@ RusticConfig { use_profiles: [], group_by: None, dry_run: false, + dry_run_warmup: false, check_index: false, log_level: None, log_file: None, diff --git a/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes-2.snap b/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes-2.snap index 65cb081a6..7a6293aec 100644 --- a/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes-2.snap +++ b/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes-2.snap @@ -5,6 +5,7 @@ expression: deserialized [global] use-profiles = [] dry-run = false +dry-run-warmup = false check-index = false no-progress = false diff --git a/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes-3.snap b/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes-3.snap index 7b6a94caa..cab4b403c 100644 --- a/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes-3.snap +++ b/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes-3.snap @@ -7,6 +7,7 @@ RusticConfig { use_profiles: [], group_by: None, dry_run: false, + dry_run_warmup: false, check_index: false, log_level: None, log_file: None, diff --git a/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes.snap b/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes.snap index 1d0218a1d..c414df7af 100644 --- a/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes.snap +++ b/src/snapshots/rustic_rs__config__tests__global_env_roundtrip_passes.snap @@ -5,6 +5,7 @@ expression: serialized [global] use-profiles = [] dry-run = false +dry-run-warmup = false check-index = false no-progress = false diff --git a/tests/snapshots/show_config__show_config_passes.snap b/tests/snapshots/show_config__show_config_passes.snap index acbb4109d..3170a64fd 100644 --- a/tests/snapshots/show_config__show_config_passes.snap +++ b/tests/snapshots/show_config__show_config_passes.snap @@ -5,6 +5,7 @@ expression: output [global] use-profiles = [] dry-run = false +dry-run-warmup = false check-index = false no-progress = false @@ -19,6 +20,8 @@ run-finally = [] [global.metrics-labels] [repository] +repository = "/tmp/repo" +password = "test" no-cache = false warm-up = false