Skip to content

Commit

Permalink
feat(fs-index): debug_assert that the path already exists in index
Browse files Browse the repository at this point in the history
Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed Sep 1, 2024
1 parent 768415c commit 7b07c9d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fs-index/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -500,12 +500,12 @@ impl<Id: ResourceId> ResourceIndex<Id> {
// 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()
Expand Down

0 comments on commit 7b07c9d

Please sign in to comment.