From c40a2f8bcc094edbf9a92d6160b623b0d5d72fa4 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 28 Nov 2022 14:26:40 +0100 Subject: [PATCH] use derive 'Default' for ChunkOrder instead of hardcoding the default deep inside the code. This makes it much easier to see what is the actual default the first instance of ChunkOrder::None was only for the test case, were the ordering doe not matter Signed-off-by: Dominik Csapak --- pbs-api-types/src/datastore.rs | 3 ++- pbs-datastore/src/datastore.rs | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index dde385c3..d75ead90 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -158,13 +158,14 @@ pub const PRUNE_SCHEMA_KEEP_YEARLY: Schema = .schema(); #[api] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] /// The order to sort chunks by pub enum ChunkOrder { /// Iterate chunks in the index order None, /// Iterate chunks in inode order + #[default] Inode, } diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index 8286b846..9a573dd7 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -72,7 +72,7 @@ impl DataStoreImpl { gc_mutex: Mutex::new(()), last_gc_status: Mutex::new(GarbageCollectionStatus::default()), verify_new: false, - chunk_order: ChunkOrder::None, + chunk_order: Default::default(), last_digest: None, sync_level: Default::default(), }) @@ -268,14 +268,13 @@ impl DataStore { DatastoreTuning::API_SCHEMA .parse_property_string(config.tuning.as_deref().unwrap_or(""))?, )?; - let chunk_order = tuning.chunk_order.unwrap_or(ChunkOrder::Inode); Ok(DataStoreImpl { chunk_store, gc_mutex: Mutex::new(()), last_gc_status: Mutex::new(gc_status), verify_new: config.verify_new.unwrap_or(false), - chunk_order, + chunk_order: tuning.chunk_order.unwrap_or_default(), last_digest, sync_level: tuning.sync_level.unwrap_or_default(), })