]> git.proxmox.com Git - proxmox-backup.git/commitdiff
use derive 'Default' for ChunkOrder
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 28 Nov 2022 13:26:40 +0000 (14:26 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 28 Nov 2022 14:59:55 +0000 (15:59 +0100)
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 <d.csapak@proxmox.com>
pbs-api-types/src/datastore.rs
pbs-datastore/src/datastore.rs

index dde385c33338273ce4e08bf3f0a35a068f971e4b..d75ead90d2cba28be64e759c9f90b427fc0d7076 100644 (file)
@@ -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,
 }
 
index 8286b846e354cd293632d04a7227dc2b9e08750c..9a573dd7b7b30775bf89d33f3c1ba277fa7a4c01 100644 (file)
@@ -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(),
         })