From a858531574f45a1b740c0d610e6d9fd2d1b1d824 Mon Sep 17 00:00:00 2001 From: Tamo Date: Wed, 25 Jan 2023 11:20:15 +0100 Subject: [PATCH] apply review comments --- file-store/src/lib.rs | 8 +++++--- index-scheduler/src/lib.rs | 4 ++-- index-scheduler/src/utils.rs | 2 +- meilisearch/src/routes/mod.rs | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/file-store/src/lib.rs b/file-store/src/lib.rs index ed36f3a91..4b7e52e5d 100644 --- a/file-store/src/lib.rs +++ b/file-store/src/lib.rs @@ -94,15 +94,17 @@ impl FileStore { Ok(()) } - pub fn update_total_size(&self) -> Result { + /// Compute the size of all the updates contained in the file store. + pub fn compute_total_size(&self) -> Result { let mut total = 0; for uuid in self.all_uuids()? { - total += self.get_size(uuid?)?; + total += self.compute_size(uuid?).unwrap_or_default(); } Ok(total) } - pub fn get_size(&self, uuid: Uuid) -> Result { + /// Compute the size of one update + pub fn compute_size(&self, uuid: Uuid) -> Result { Ok(self.get_update(uuid)?.metadata()?.len()) } diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index f880979be..387dac2d0 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -903,8 +903,8 @@ impl IndexScheduler { } /// The size on disk taken by all the updates files contained in the `IndexScheduler`, in bytes. - pub fn update_file_size(&self) -> Result { - Ok(self.file_store.update_total_size()?) + pub fn compute_update_file_size(&self) -> Result { + Ok(self.file_store.compute_total_size()?) } /// Delete a file from the index scheduler. diff --git a/index-scheduler/src/utils.rs b/index-scheduler/src/utils.rs index b3982c19a..c9b71b523 100644 --- a/index-scheduler/src/utils.rs +++ b/index-scheduler/src/utils.rs @@ -514,7 +514,7 @@ impl IndexScheduler { .unwrap() .any(|uuid| uuid.as_ref().unwrap() == &content_file), "Could not find uuid `{content_file}` in the file_store. Available uuids are {:?}.", - self.file_store.all_uuids().unwrap().collect::>>().unwrap(), + self.file_store.all_uuids().unwrap().collect::, file_store::Error>>().unwrap(), ); } Status::Succeeded | Status::Failed | Status::Canceled => { diff --git a/meilisearch/src/routes/mod.rs b/meilisearch/src/routes/mod.rs index eaf014a81..7aaad7125 100644 --- a/meilisearch/src/routes/mod.rs +++ b/meilisearch/src/routes/mod.rs @@ -281,7 +281,7 @@ pub fn create_all_stats( database_size += index_scheduler.size()?; database_size += auth_controller.size()?; - database_size += index_scheduler.update_file_size()?; + database_size += index_scheduler.compute_update_file_size()?; let stats = Stats { database_size, last_update: last_task, indexes }; Ok(stats)