diff --git a/Cargo.lock b/Cargo.lock index a8bd1f0..3411db8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -236,6 +236,7 @@ dependencies = [ "digest", "displaydoc", "ed25519-compact", + "fastcdc", "futures", "hex", "lazy_static", @@ -309,7 +310,6 @@ dependencies = [ "digest", "displaydoc", "enum-as-inner", - "fastcdc", "futures", "hex", "http-body-util", diff --git a/attic/Cargo.toml b/attic/Cargo.toml index 4cf79f2..ceaee24 100644 --- a/attic/Cargo.toml +++ b/attic/Cargo.toml @@ -11,6 +11,7 @@ bytes = "1.4.0" displaydoc = "0.2.4" digest = "0.10.7" ed25519-compact = "2.0.4" +fastcdc = "3.0.3" futures = "0.3.28" hex = "0.4.3" lazy_static = "1.4.0" @@ -51,11 +52,15 @@ version-compare = "0.2.0" [features] default = [ + "chunking", "nix_store", "stream", "tokio", ] +# Chunking. +chunking = ["tokio", "dep:async-stream"] + # Native libnixstore bindings. # # When disabled, the native Rust portions of nix_store can still be used. diff --git a/server/src/chunking/mod.rs b/attic/src/chunking/mod.rs similarity index 98% rename from server/src/chunking/mod.rs rename to attic/src/chunking/mod.rs index b567847..00862ef 100644 --- a/server/src/chunking/mod.rs +++ b/attic/src/chunking/mod.rs @@ -9,7 +9,7 @@ use fastcdc::ronomon::FastCDC; use futures::stream::Stream; use tokio::io::AsyncRead; -use attic::stream::read_chunk_async; +use crate::stream::read_chunk_async; /// Splits a streams into content-defined chunks. /// diff --git a/attic/src/lib.rs b/attic/src/lib.rs index 04ff0fd..8cc2cec 100644 --- a/attic/src/lib.rs +++ b/attic/src/lib.rs @@ -17,6 +17,8 @@ pub mod api; pub mod cache; +#[cfg(feature = "chunking")] +pub mod chunking; pub mod error; pub mod hash; pub mod mime; diff --git a/server/Cargo.toml b/server/Cargo.toml index ec50929..3fcf108 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -19,7 +19,7 @@ path = "src/adm/main.rs" doc = false [dependencies] -attic = { path = "../attic", default-features = false, features = ["stream", "tokio"] } +attic = { path = "../attic", default-features = false, features = ["chunking", "stream", "tokio"] } attic-token = { path = "../token" } anyhow = "1.0.71" @@ -37,7 +37,6 @@ derivative = "2.2.0" digest = "0.10.7" displaydoc = "0.2.4" enum-as-inner = "0.6.0" -fastcdc = "3.0.3" futures = "0.3.28" hex = "0.4.3" http-body-util = "0.1.1" diff --git a/server/src/api/v1/upload_path.rs b/server/src/api/v1/upload_path.rs index 4b04601..049795d 100644 --- a/server/src/api/v1/upload_path.rs +++ b/server/src/api/v1/upload_path.rs @@ -37,11 +37,11 @@ use attic::api::v1::upload_path::{ UploadPathNarInfo, UploadPathResult, UploadPathResultKind, ATTIC_NAR_INFO, ATTIC_NAR_INFO_PREAMBLE_SIZE, }; +use attic::chunking::chunk_stream; use attic::hash::Hash; use attic::stream::{read_chunk_async, StreamHasher}; use attic::util::Finally; -use crate::chunking::chunk_stream; use crate::database::entity::cache; use crate::database::entity::chunk::{self, ChunkState, Entity as Chunk}; use crate::database::entity::chunkref::{self, Entity as ChunkRef}; diff --git a/server/src/lib.rs b/server/src/lib.rs index 93f2e0b..0314e69 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -15,7 +15,6 @@ pub mod access; mod api; -mod chunking; pub mod config; pub mod database; pub mod error;