From 50e1b19b750f620aac61ef6331218db77e75eb72 Mon Sep 17 00:00:00 2001 From: Tarek Date: Wed, 28 Feb 2024 18:59:02 +0200 Subject: [PATCH] refactor: define a crate data-link to handle links-related code Signed-off-by: Tarek --- Cargo.toml | 2 ++ data-link/Cargo.toml | 27 ++++++++++++++++++++ fs-index/src/link.rs => data-link/src/lib.rs | 11 ++++---- fs-index/Cargo.toml | 4 --- fs-index/src/lib.rs | 3 +-- 5 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 data-link/Cargo.toml rename fs-index/src/link.rs => data-link/src/lib.rs (98%) diff --git a/Cargo.toml b/Cargo.toml index a98e29b2..4b792015 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ members = [ "data-error", "data-json", + "data-link", "data-pdf", "data-resource", "fs-atomic-versions", @@ -12,6 +13,7 @@ members = [ default-members = [ "data-error", "data-json", + "data-link", "data-pdf", "data-resource", "fs-atomic-versions", diff --git a/data-link/Cargo.toml b/data-link/Cargo.toml new file mode 100644 index 00000000..30be2315 --- /dev/null +++ b/data-link/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "data-link" +version = "0.1.0" +edition = "2021" + + +[lib] +name = "data_link" +crate-type = ["rlib"] +bench = false + +[dependencies] +fs-index = { path = "../fs-index" } +fs-atomic-versions = { path = "../fs-atomic-versions" } +fs-utils = { path = "../fs-utils" } +data-resource = { path = "../data-resource" } + +log = { version = "0.4.17", features = ["release_max_level_off"] } +serde_json = "1.0.82" +serde = { version = "1.0.138", features = ["derive"] } +url = { version = "2.2.2", features = ["serde"] } +reqwest = "0.11.11" +scraper = "0.13.0" +tokio = { version = "1", features = ["full"] } + +[dev-dependencies] +tempdir = "0.3.7" diff --git a/fs-index/src/link.rs b/data-link/src/lib.rs similarity index 98% rename from fs-index/src/link.rs rename to data-link/src/lib.rs index ea5dc738..a1e60781 100644 --- a/fs-index/src/link.rs +++ b/data-link/src/lib.rs @@ -1,10 +1,11 @@ -use crate::storage::meta::store_metadata; -use crate::storage::prop::store_properties; -use crate::{ - storage::prop::load_raw_properties, AtomicFile, Result, ARK_FOLDER, +use data_resource::ResourceId; +use fs_index::storage::meta::store_metadata; +use fs_index::storage::prop::store_properties; +use fs_index::{ + storage::prop::load_raw_properties, AtomicFile, ARK_FOLDER, PREVIEWS_STORAGE_FOLDER, PROPERTIES_STORAGE_FOLDER, }; -use data_resource::ResourceId; +use fs_utils::errors::Result; use reqwest::header::HeaderValue; use scraper::{Html, Selector}; use serde::{Deserialize, Serialize}; diff --git a/fs-index/Cargo.toml b/fs-index/Cargo.toml index 99f37756..d76e0d37 100644 --- a/fs-index/Cargo.toml +++ b/fs-index/Cargo.toml @@ -21,10 +21,6 @@ canonical-path = "2.0.2" pathdiff = "0.2.1" serde_json = "1.0.82" serde = { version = "1.0.138", features = ["derive"] } -url = { version = "2.2.2", features = ["serde"] } -reqwest = "0.11.11" -scraper = "0.13.0" -tokio = { version = "1", features = ["full"] } itertools = "0.10.5" [dev-dependencies] diff --git a/fs-index/src/lib.rs b/fs-index/src/lib.rs index b5dd01ad..4b3ea86c 100644 --- a/fs-index/src/lib.rs +++ b/fs-index/src/lib.rs @@ -6,9 +6,8 @@ extern crate canonical_path; use fs_utils::errors::{ArklibError, Result}; pub mod index; -pub mod link; -mod storage; +pub mod storage; pub use fs_atomic_versions::atomic::{modify, modify_json, AtomicFile};