From 7b07c9db8e193f9d0f47f510c03dba5de62d1ba6 Mon Sep 17 00:00:00 2001 From: Tarek Date: Sun, 1 Sep 2024 19:50:57 +0300 Subject: [PATCH] feat(fs-index): debug_assert that the path already exists in index Signed-off-by: Tarek --- fs-index/src/index.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs-index/src/index.rs b/fs-index/src/index.rs index ac13d98f..6746ac29 100644 --- a/fs-index/src/index.rs +++ b/fs-index/src/index.rs @@ -8,7 +8,7 @@ use std::{ use serde::{Deserialize, Serialize}; -use data_error::{ArklibError, Result}; +use data_error::Result; use data_resource::ResourceId; use fs_storage::{ARK_FOLDER, INDEX_PATH}; @@ -500,12 +500,12 @@ impl ResourceIndex { // If the entry does not exist in the file system, it's a removal // Remove the resource from the path to ID map - let id = self.path_to_id.remove(path).ok_or_else(|| { - ArklibError::Path(format!( - "Path {:?} not found in the index", - path - )) - })?; + debug_assert!( + self.path_to_id.contains_key(path), + "Caller must ensure that the resource exists in the index: {:?}", + path + ); + let id = self.path_to_id.remove(path).unwrap(); self.id_to_paths .get_mut(&id.item) .unwrap()