diff options
Diffstat (limited to 'adenosine-pds/src/car.rs')
-rw-r--r-- | adenosine-pds/src/car.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/adenosine-pds/src/car.rs b/adenosine-pds/src/car.rs index 35cc3fd..63911e5 100644 --- a/adenosine-pds/src/car.rs +++ b/adenosine-pds/src/car.rs @@ -8,28 +8,30 @@ use std::path::PathBuf; use tokio::fs::File; use tokio::io::BufReader; -pub fn load_car_to_sqlite(db_path: &PathBuf, car_path: &PathBuf) -> Result<()> { +pub fn load_car_to_sqlite(db_path: &PathBuf, car_path: &PathBuf, alias: &str) -> 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, alias)?; Ok(()) } pub fn load_car_to_blockstore( db: &mut BlockStore<libipld::DefaultParams>, car_path: &PathBuf, + alias: &str, ) -> Result<Cid> { let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build()?; - rt.block_on(inner_car_loader(db, car_path)) + rt.block_on(inner_car_loader(db, car_path, alias)) } // this async function is wrapped in the sync version above async fn inner_car_loader( db: &mut BlockStore<libipld::DefaultParams>, car_path: &PathBuf, + alias: &str, ) -> Result<Cid> { println!( "{} - {}", @@ -55,7 +57,7 @@ async fn inner_car_loader( // pin the header (?) if car_header.roots().len() >= 1 { - db.alias(b"import".to_vec(), Some(&car_header.roots()[0]))?; + db.alias(alias.as_bytes(), Some(&car_header.roots()[0]))?; } Ok(car_header.roots()[0]) |