Skip to content

Commit

Permalink
fix no default features
Browse files Browse the repository at this point in the history
  • Loading branch information
rklaehn committed Jan 2, 2025
1 parent a3bef55 commit 32a35ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ pub mod fs;
mod fetch_to_db;
pub use fetch_to_db::{fetch_to_db, fetch_to_db_in_steps, FetchState, FetchStateNeedsConn};
mod export;
pub use export::{export, export_blob, export_collection, ExportProgress};
#[cfg(feature = "formats-collection")]
pub use export::export_collection;
pub use export::{export, export_blob, ExportProgress};

mod traits;
use tracing::warn;
Expand Down
6 changes: 4 additions & 2 deletions src/store/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use serde::{Deserialize, Serialize};
use tracing::trace;

use crate::{
format::collection::Collection,
store::{BaoBlobSize, ExportFormat, ExportMode, MapEntry, Store as BaoStore},
util::progress::{IdGenerator, ProgressSender},
Hash,
Expand All @@ -32,11 +31,13 @@ pub async fn export<D: BaoStore>(
) -> anyhow::Result<()> {
match format {
ExportFormat::Blob => export_blob(db, hash, outpath, mode, progress).await,
#[cfg(feature = "formats-collection")]
ExportFormat::Collection => export_collection(db, hash, outpath, mode, progress).await,
}
}

/// Export all entries of a collection, recursively, to files on the local filesystem.
#[cfg(feature = "formats-collection")]
pub async fn export_collection<D: BaoStore>(
db: &D,
hash: Hash,
Expand All @@ -45,7 +46,7 @@ pub async fn export_collection<D: BaoStore>(
progress: impl ProgressSender<Msg = ExportProgress> + IdGenerator,
) -> anyhow::Result<()> {
tokio::fs::create_dir_all(&outpath).await?;
let collection = Collection::load_db(db, &hash).await?;
let collection = crate::format::collection::Collection::load_db(db, &hash).await?;
for (name, hash) in collection.into_iter() {
#[allow(clippy::needless_borrow)]
let path = outpath.join(pathbuf_from_name(&name));
Expand Down Expand Up @@ -126,6 +127,7 @@ pub enum ExportProgress {
Abort(serde_error::Error),
}

#[cfg(feature = "formats-collection")]
fn pathbuf_from_name(name: &str) -> PathBuf {
let mut path = PathBuf::new();
for part in name.split('/') {
Expand Down
1 change: 1 addition & 0 deletions src/store/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ pub enum ExportFormat {
/// destination path.
///
/// If the blob cannot be parsed as a collection, the operation will fail.
#[cfg(feature = "formats-collection")]
Collection,
}

Expand Down

0 comments on commit 32a35ca

Please sign in to comment.