diff options
author | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-05 15:36:47 +0100 |
---|---|---|
committer | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-05 15:36:47 +0100 |
commit | f914db057a85e0fa70f319ee3af85998a551af96 (patch) | |
tree | d5a805dbc0615544d3fe1b1b538fbf2a3642a74a /src/garage/cli/repair.rs | |
parent | 406b6da1634a38c1b8176ff468d964e42ce5ce5d (diff) | |
download | garage-f914db057a85e0fa70f319ee3af85998a551af96.tar.gz garage-f914db057a85e0fa70f319ee3af85998a551af96.zip |
cli_v2: implement LaunchRepairOperation and remove old stuff
Diffstat (limited to 'src/garage/cli/repair.rs')
-rw-r--r-- | src/garage/cli/repair.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/garage/cli/repair.rs b/src/garage/cli/repair.rs new file mode 100644 index 00000000..45024e71 --- /dev/null +++ b/src/garage/cli/repair.rs @@ -0,0 +1,47 @@ +use std::path::PathBuf; + +use garage_util::config::*; +use garage_util::error::*; + +use garage_model::garage::Garage; + +use crate::cli::structs::*; +use crate::secrets::{fill_secrets, Secrets}; + +pub async fn offline_repair( + config_file: PathBuf, + secrets: Secrets, + opt: OfflineRepairOpt, +) -> Result<(), Error> { + if !opt.yes { + return Err(Error::Message( + "Please add the --yes flag to launch repair operation".into(), + )); + } + + info!("Loading configuration..."); + let config = fill_secrets(read_config(config_file)?, secrets)?; + + info!("Initializing Garage main data store..."); + let garage = Garage::new(config)?; + + info!("Launching repair operation..."); + match opt.what { + #[cfg(feature = "k2v")] + OfflineRepairWhat::K2VItemCounters => { + garage + .k2v + .counter_table + .offline_recount_all(&garage.k2v.item_table)?; + } + OfflineRepairWhat::ObjectCounters => { + garage + .object_counter_table + .offline_recount_all(&garage.object_table)?; + } + } + + info!("Repair operation finished, shutting down..."); + + Ok(()) +} |