Skip to content

Commit

Permalink
fix ResourceId imports in crates
Browse files Browse the repository at this point in the history
Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed May 12, 2024
1 parent 6135ff5 commit 36b4282
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
8 changes: 4 additions & 4 deletions data-link/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use data_error::Result;
use data_resource::{Resource, ResourceId, ResourceIdTrait};
use data_resource::{ResourceId, ResourceIdTrait};
use fs_atomic_versions::atomic::AtomicFile;
use fs_metadata::store_metadata;
use fs_properties::load_raw_properties;
Expand Down Expand Up @@ -36,7 +36,7 @@ impl Link {
}

pub fn id(&self) -> Result<ResourceId> {
Resource::from_bytes(self.url.as_str().as_bytes())
ResourceId::from_bytes(self.url.as_str().as_bytes())
}

fn load_user_data<P: AsRef<Path>>(
Expand All @@ -60,7 +60,7 @@ impl Link {
pub fn load<P: AsRef<Path>>(root: P, filename: P) -> Result<Self> {
let p = root.as_ref().join(filename);
let url = Self::load_url(p)?;
let id = Resource::from_bytes(url.as_str().as_bytes())?;
let id = ResourceId::from_bytes(url.as_str().as_bytes())?;
// Load user properties first
let user_prop = Self::load_user_data(&root, &id)?;
let mut description = user_prop.desc;
Expand Down Expand Up @@ -319,7 +319,7 @@ async fn test_create_link_file() {
assert_eq!(link.prop.desc.unwrap(), "test_desc");
assert_eq!(link.prop.title, "test_title");

let id = Resource::from_bytes(current_bytes.as_bytes()).unwrap();
let id = ResourceId::from_bytes(current_bytes.as_bytes()).unwrap();
let path = Path::new(&root)
.join(ARK_FOLDER)
.join(PREVIEWS_STORAGE_FOLDER)
Expand Down
4 changes: 1 addition & 3 deletions fs-index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ fs-storage = { path = "../fs-storage" }

# For now, we are explicitly using the non-cryptographic CRC-32 hash
# The developer is responsible for specifying consistent hash function in other crates
data-resource = { path = "../data-resource", features = [
"hash_blake3",
] }
data-resource = { path = "../data-resource", features = ["hash_crc32"] }

log = { version = "0.4.17", features = ["release_max_level_off"] }
walkdir = "2.3.2"
Expand Down
10 changes: 2 additions & 8 deletions fs-index/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ use walkdir::{DirEntry, WalkDir};
use log;

use crate::{ArklibError, Result, ARK_FOLDER, INDEX_PATH};
use data_resource;

//todo: this is not the way to go:
#[cfg(feature = "hash_blake3")]
use data_resource::blake3::ResourceId as ResourceId;
#[cfg(not(feature = "hash_blake3"))]
use data_resource::crc32::ResourceId as ResourceId;
use data_resource::{ResourceId, ResourceIdTrait};

#[derive(Eq, Ord, PartialEq, PartialOrd, Hash, Clone, Debug)]
pub struct IndexEntry {
Expand Down Expand Up @@ -631,7 +625,7 @@ fn scan_entry(path: &CanonicalPath, metadata: Metadata) -> Result<IndexEntry> {
))?;
}

let id = data_resource::ResourceId::from_path(path)?;
let id = ResourceId::from_path(path)?;
let modified = metadata.modified()?;

Ok(IndexEntry { id, modified })
Expand Down

0 comments on commit 36b4282

Please sign in to comment.