diff --git a/Cargo.toml b/Cargo.toml index 493509d..295d5f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,4 +32,5 @@ features = ["extension-module","abi3-py36"] [features] default = ["jemalloc"] -jemalloc = [] \ No newline at end of file +jemalloc = [] +no-progress-bars = [] diff --git a/auto_compressor/Cargo.toml b/auto_compressor/Cargo.toml index 13e3874..46c84a6 100644 --- a/auto_compressor/Cargo.toml +++ b/auto_compressor/Cargo.toml @@ -14,7 +14,7 @@ postgres-openssl = "0.5.0" jemallocator = "0.3.2" rand = "0.8.0" serial_test = "0.5.1" -synapse_compress_state = { path = "../" } +synapse_compress_state = { path = "../", features = ["no-progress-bars"] } env_logger = { version = "0.9.0", git = "https://github.com/TilCreator/env_logger", branch = "fix_pipe" } log = "0.4.14" log-panics = "2.0.0" diff --git a/compressor_integration_tests/Cargo.toml b/compressor_integration_tests/Cargo.toml index 89b30e1..a03fe2a 100644 --- a/compressor_integration_tests/Cargo.toml +++ b/compressor_integration_tests/Cargo.toml @@ -12,7 +12,7 @@ openssl = "0.10.32" postgres = "0.19.0" postgres-openssl = "0.5.0" rand = "0.8.0" -synapse_compress_state = { path = "../" } +synapse_compress_state = { path = "../", features = ["no-progress-bars"] } auto_compressor = { path = "../auto_compressor/" } env_logger = "0.9.0" log = "0.4.14" diff --git a/src/compressor.rs b/src/compressor.rs index c4eb892..ea74e01 100644 --- a/src/compressor.rs +++ b/src/compressor.rs @@ -181,7 +181,12 @@ impl<'a> Compressor<'a> { panic!("Can only call `create_new_tree` once"); } - let pb = ProgressBar::new(self.original_state_map.len() as u64); + let pb: ProgressBar; + if cfg!(feature = "no-progress-bars") { + pb = ProgressBar::hidden(); + } else { + pb = ProgressBar::new(self.original_state_map.len() as u64); + } pb.set_style( ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"), ); diff --git a/src/database.rs b/src/database.rs index 7da15d8..1808f56 100644 --- a/src/database.rs +++ b/src/database.rs @@ -373,7 +373,12 @@ fn get_initial_data_from_db( // Copy the data from the database into a map let mut state_group_map: BTreeMap = BTreeMap::new(); - let pb = ProgressBar::new_spinner(); + let pb: ProgressBar; + if cfg!(feature = "no-progress-bars") { + pb = ProgressBar::hidden(); + } else { + pb = ProgressBar::new_spinner(); + } pb.set_style( ProgressStyle::default_spinner().template("{spinner} [{elapsed}] {pos} rows retrieved"), ); @@ -533,7 +538,12 @@ pub fn send_changes_to_db( println!("Writing changes..."); // setup the progress bar - let pb = ProgressBar::new(old_map.len() as u64); + let pb: ProgressBar; + if cfg!(feature = "no-progress-bars") { + pb = ProgressBar::hidden(); + } else { + pb = ProgressBar::new(old_map.len() as u64); + } pb.set_style( ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"), ); diff --git a/src/lib.rs b/src/lib.rs index 87d250b..6ffd351 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -487,7 +487,12 @@ fn output_sql( println!("Writing changes..."); - let pb = ProgressBar::new(old_map.len() as u64); + let pb: ProgressBar; + if cfg!(feature = "no-progress-bars") { + pb = ProgressBar::hidden(); + } else { + pb = ProgressBar::new(old_map.len() as u64); + } pb.set_style( ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"), ); @@ -597,7 +602,12 @@ fn check_that_maps_match( ) { println!("Checking that state maps match..."); - let pb = ProgressBar::new(old_map.len() as u64); + let pb: ProgressBar; + if cfg!(feature = "no-progress-bars") { + pb = ProgressBar::hidden(); + } else { + pb = ProgressBar::new(old_map.len() as u64); + } pb.set_style( ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"), );