Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor out fs-metadata and fs-properties crates from fs-storage #14

Merged
merged 4 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ members = [
"data-resource",
"fs-atomic-versions",
"fs-atomic-light",
"fs-metadata",
"fs-properties",
"fs-index",
"fs-storage",
]
Expand All @@ -18,6 +20,9 @@ default-members = [
"data-pdf",
"data-resource",
"fs-atomic-versions",
"fs-atomic-light",
"fs-metadata",
"fs-properties",
"fs-index",
"fs-storage",
]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The purpose of the library is to manage _resource index_ of folders with various
| `data-resource` | Resource hashing and ID construction |
| `fs-index` | Resource Index construction and updating |
| `fs-storage` | Filesystem storage for resources |
| `fs-metadata` | Metadata management |
| `fs-properties` | Properties management |
| `data-link` | Linking resources |
| `data-pdf` | PDF handling |
| `data-error` | Error handling |
Expand Down
5 changes: 5 additions & 0 deletions data-error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name = "data-error"
version = "0.1.0"
edition = "2021"

[lib]
name = "data_error"
crate-type = ["rlib"]
bench = false

[dependencies]
thiserror = "1"
reqwest = "0.11.11"
Expand Down
4 changes: 4 additions & 0 deletions data-json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name = "data-json"
version = "0.1.0"
edition = "2021"

[lib]
name = "data_json"
crate-type = ["rlib"]
bench = false

[dependencies]
serde_json = "1.0.82"
Expand Down
3 changes: 3 additions & 0 deletions data-link/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ edition = "2021"
[lib]
name = "data_link"
crate-type = ["rlib"]
bench = false

[dependencies]
fs-atomic-light = { path = "../fs-atomic-light" }
fs-atomic-versions = { path = "../fs-atomic-versions" }
fs-storage = { path = "../fs-storage" }
fs-metadata = { path = "../fs-metadata" }
fs-properties = { path = "../fs-properties" }
data-resource = { path = "../data-resource" }
data-error = { path = "../data-error" }

Expand Down
11 changes: 5 additions & 6 deletions data-link/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use data_error::Result;
use data_resource::ResourceId;
use fs_atomic_versions::atomic::AtomicFile;
use fs_storage::meta::store_metadata;
use fs_storage::prop::load_raw_properties;
use fs_storage::prop::store_properties;
use fs_storage::{
ARK_FOLDER, PREVIEWS_STORAGE_FOLDER, PROPERTIES_STORAGE_FOLDER,
};
use fs_metadata::store_metadata;
use fs_properties::load_raw_properties;
use fs_properties::store_properties;
use fs_properties::PROPERTIES_STORAGE_FOLDER;
use fs_storage::{ARK_FOLDER, PREVIEWS_STORAGE_FOLDER};
use reqwest::header::HeaderValue;
use scraper::{Html, Selector};
use serde::{Deserialize, Serialize};
Expand Down
3 changes: 2 additions & 1 deletion data-pdf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ edition = "2021"
[lib]
name = "data_pdf"
crate-type = ["rlib"]
bench = false

[dependencies]
once_cell = "1.16.0"
image = "0.24.2"
image = "=0.25.0"
pdfium-render = { git = "https://github.com/ajrcarey/pdfium-render", rev = "d2559c1", features = [
"thread_safe",
"sync",
Expand Down
1 change: 1 addition & 0 deletions fs-atomic-light/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
[lib]
name = "fs_atomic_light"
crate-type = ["rlib"]
bench = false

[dependencies]
data-error = { path = "../data-error" }
1 change: 1 addition & 0 deletions fs-atomic-versions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
[lib]
name = "fs_atomic_versions"
crate-type = ["rlib"]
bench = false

[dependencies]
data-error = { path = "../data-error" }
Expand Down
21 changes: 21 additions & 0 deletions fs-metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "fs-metadata"
version = "0.1.0"
edition = "2021"

[lib]
name = "fs_metadata"
crate-type = ["rlib"]
bench = false

[dependencies]
data-error = { path = "../data-error" }
fs-atomic-versions = { path = "../fs-atomic-versions" }
data-resource = { path = "../data-resource" }
fs-storage = { path = "../fs-storage" }
serde = { version = "1.0.138", features = ["derive"] }

[dev-dependencies]
log = { version = "0.4.17", features = ["release_max_level_off"] }
tempdir = "0.3.7"
serde_json = "1.0.82"
4 changes: 3 additions & 1 deletion fs-storage/src/meta.rs → fs-metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ use std::fmt::Debug;
use std::io::Read;
use std::path::Path;

use crate::{ARK_FOLDER, METADATA_STORAGE_FOLDER};
use data_resource::ResourceId;
use fs_storage::ARK_FOLDER;

pub const METADATA_STORAGE_FOLDER: &str = "cache/metadata";

pub fn store_metadata<
S: Serialize + DeserializeOwned + Clone + Debug,
Expand Down
23 changes: 23 additions & 0 deletions fs-properties/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "fs-properties"
version = "0.1.0"
edition = "2021"

[lib]
name = "fs_properties"
crate-type = ["rlib"]
bench = false

[dependencies]
data-error = { path = "../data-error" }
data-json = { path = "../data-json" }
fs-atomic-versions = { path = "../fs-atomic-versions" }
fs-storage = { path = "../fs-storage" }
data-resource = { path = "../data-resource" }

serde_json = "1.0.82"
serde = { version = "1.0.138", features = ["derive"] }

[dev-dependencies]
log = { version = "0.4.17", features = ["release_max_level_off"] }
tempdir = "0.3.7"
4 changes: 3 additions & 1 deletion fs-storage/src/prop.rs → fs-properties/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ use std::fmt::Debug;
use std::io::Read;
use std::path::Path;

use crate::{ARK_FOLDER, PROPERTIES_STORAGE_FOLDER};
use data_resource::ResourceId;
use fs_storage::ARK_FOLDER;

pub const PROPERTIES_STORAGE_FOLDER: &str = "user/properties";

pub fn store_properties<
S: Serialize + DeserializeOwned + Clone + Debug,
Expand Down
15 changes: 4 additions & 11 deletions fs-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@ name = "fs-storage"
version = "0.1.0"
edition = "2021"

[lib]
name = "fs_storage"
crate-type = ["rlib"]
bench = false

[dependencies]
data-error = { path = "../data-error" }
data-json = { path = "../data-json" }
fs-atomic-versions = { path = "../fs-atomic-versions" }
data-resource = { path = "../data-resource" }

serde_json = "1.0.82"
serde = { version = "1.0.138", features = ["derive"] }

[dev-dependencies]
log = { version = "0.4.17", features = ["release_max_level_off"] }
tempdir = "0.3.7"
5 changes: 0 additions & 5 deletions fs-storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
pub mod meta;
pub mod prop;

pub const ARK_FOLDER: &str = ".ark";

// Should not be lost if possible
Expand All @@ -10,10 +7,8 @@ pub const FAVORITES_FILE: &str = "favorites";
// User-defined data
pub const TAG_STORAGE_FILE: &str = "user/tags";
pub const SCORE_STORAGE_FILE: &str = "user/scores";
pub const PROPERTIES_STORAGE_FOLDER: &str = "user/properties";

// Generated data
pub const INDEX_PATH: &str = "index";
pub const METADATA_STORAGE_FOLDER: &str = "cache/metadata";
pub const PREVIEWS_STORAGE_FOLDER: &str = "cache/previews";
pub const THUMBNAILS_STORAGE_FOLDER: &str = "cache/thumbnails";
Loading