diff options
Diffstat (limited to 'adenosine-pds/src/car.rs')
-rw-r--r-- | adenosine-pds/src/car.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/adenosine-pds/src/car.rs b/adenosine-pds/src/car.rs index 5731848..35cc3fd 100644 --- a/adenosine-pds/src/car.rs +++ b/adenosine-pds/src/car.rs @@ -3,7 +3,7 @@ use anyhow::Result; use futures::TryStreamExt; use ipfs_sqlite_block_store::BlockStore; use iroh_car::CarReader; -use libipld::block::Block; +use libipld::{Block, Cid}; use std::path::PathBuf; use tokio::fs::File; use tokio::io::BufReader; @@ -12,13 +12,14 @@ pub fn load_car_to_sqlite(db_path: &PathBuf, car_path: &PathBuf) -> Result<()> { let mut db: BlockStore<libipld::DefaultParams> = { BlockStore::open(db_path, Default::default())? }; - load_car_to_blockstore(&mut db, car_path) + load_car_to_blockstore(&mut db, car_path)?; + Ok(()) } pub fn load_car_to_blockstore( db: &mut BlockStore<libipld::DefaultParams>, car_path: &PathBuf, -) -> Result<()> { +) -> Result<Cid> { let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build()?; @@ -29,7 +30,7 @@ pub fn load_car_to_blockstore( async fn inner_car_loader( db: &mut BlockStore<libipld::DefaultParams>, car_path: &PathBuf, -) -> Result<()> { +) -> Result<Cid> { println!( "{} - {}", std::env::current_dir()?.display(), @@ -52,10 +53,10 @@ async fn inner_car_loader( }) .await?; - // pin the header + // pin the header (?) if car_header.roots().len() >= 1 { db.alias(b"import".to_vec(), Some(&car_header.roots()[0]))?; } - Ok(()) + Ok(car_header.roots()[0]) } |