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

fs-cache: Add Cache Struct #95

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"data-pdf",
"data-resource",
"fs-atomic-versions",
"fs-cache",
"fs-atomic-light",
"fs-metadata",
"fs-properties",
Expand All @@ -23,6 +24,7 @@ default-members = [
"data-pdf",
"data-resource",
"fs-atomic-versions",
"fs-cache",
"fs-atomic-light",
"fs-metadata",
"fs-properties",
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ The core crate is `fs-index` which provides us with [content addressing](https:/

<div align="center">

| Package | Description |
| --------------- | ---------------------------------------- |
| `ark-cli` | The CLI tool to interact with ark crates |
| `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 |
| `data-json` | JSON serialization and deserialization |
| Package | Description |
| --------------- | ---------------------------------------- |
| `ark-cli` | The CLI tool to interact with ark crates |
| `data-resource` | Resource hashing and ID construction |
| `fs-cache` | Memory and disk caching with LRU eviction |
| `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 |
| `data-json` | JSON serialization and deserialization |

</div>

Expand Down
7 changes: 3 additions & 4 deletions ark-cli/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,9 @@ pub fn translate_storage(
root: &Option<PathBuf>,
storage: &str,
) -> Option<(PathBuf, Option<StorageType>)> {
if let Ok(path) = PathBuf::from_str(storage) {
if path.exists() && path.is_dir() {
return Some((path, None));
}
let Ok(path) = PathBuf::from_str(storage);
if path.exists() && path.is_dir() {
return Some((path, None));
}

match storage.to_lowercase().as_str() {
Expand Down
2 changes: 1 addition & 1 deletion fs-atomic-versions/src/atomic/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl AtomicFile {

/// Return the latest version together with vector of the
/// files matching this version. Multiple files for the same version
/// can appear due to usage of file syncronization. Different devices
/// can appear due to usage of file synchronization. Different devices
/// can create same version simultaneously.
pub fn latest_version(&self) -> Result<(usize, Vec<ReadOnlyFile>)> {
let files_iterator = fs::read_dir(&self.directory)?.flatten();
Expand Down
20 changes: 20 additions & 0 deletions fs-cache/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "fs-cache"
version = "0.1.0"
edition = "2021"

[lib]
name = "fs_cache"
crate-type = ["rlib", "cdylib"]
bench = false

[dependencies]
log = { version = "0.4.17", features = ["release_max_level_off"] }
data-error = { path = "../data-error" }
fs-storage = { path = "../fs-storage"}
fs-atomic-light = { path = "../fs-atomic-light" }
lru = "0.12.5"

[dev-dependencies]
tempdir = "0.3.7"
rstest = "0.23"
Loading