summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-05-24 08:55:14 +0300
committerLars Wirzenius <liw@liw.fi>2021-05-29 11:41:15 +0300
commit6de230c382a4329df00bc11cc1ffb90390b13159 (patch)
treed4f0668be0d5cd07ea32af2b0978696658532122 /src/bin
parent566dd94d2e46c489b50d84a1fd24683460e5cfdc (diff)
downloadobnam2-6de230c382a4329df00bc11cc1ffb90390b13159.tar.gz
refactor: make metadata be part of datachunk
This makes it harder to lose the metadata for a chunk, or to use unrelated metadata and chunk. Also, soon I will refactor things for encrypting chunks, which will need metadata embedded in the encrypted chunk. Sponsored-by: author
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/benchmark-index.rs7
-rw-r--r--src/bin/benchmark-indexedstore.rs8
-rw-r--r--src/bin/benchmark-null.rs2
-rw-r--r--src/bin/benchmark-store.rs4
-rw-r--r--src/bin/obnam-server.rs6
5 files changed, 14 insertions, 13 deletions
diff --git a/src/bin/benchmark-index.rs b/src/bin/benchmark-index.rs
index 9baa327..b5a059c 100644
--- a/src/bin/benchmark-index.rs
+++ b/src/bin/benchmark-index.rs
@@ -60,7 +60,8 @@ fn create(chunks: &Path, num: u32) -> anyhow::Result<()> {
let mut index = Index::new(chunks)?;
let gen = ChunkGenerator::new(num);
- for (id, _, meta, _) in gen {
+ for (id, _, chunk) in gen {
+ let meta = (*chunk.meta()).clone();
index.insert_meta(id, meta)?;
}
@@ -82,8 +83,8 @@ fn lookup(index: &mut Index, num: u32) -> anyhow::Result<()> {
loop {
let gen = ChunkGenerator::new(num);
- for (_, _, meta, _) in gen {
- index.find_by_sha256(&meta.sha256())?;
+ for (_, _, chunk) in gen {
+ index.find_by_sha256(&chunk.meta().sha256())?;
done += 1;
if done >= num {
return Ok(());
diff --git a/src/bin/benchmark-indexedstore.rs b/src/bin/benchmark-indexedstore.rs
index acc3bd3..5cd3ff1 100644
--- a/src/bin/benchmark-indexedstore.rs
+++ b/src/bin/benchmark-indexedstore.rs
@@ -60,8 +60,8 @@ fn create(chunks: &Path, num: u32) -> anyhow::Result<()> {
let mut store = IndexedStore::new(chunks)?;
let gen = ChunkGenerator::new(num);
- for (_, _, meta, chunk) in gen {
- store.save(&meta, &chunk)?;
+ for (_, _, chunk) in gen {
+ store.save(&chunk)?;
}
Ok(())
@@ -82,8 +82,8 @@ fn lookup(index: &mut IndexedStore, num: u32) -> anyhow::Result<()> {
loop {
let gen = ChunkGenerator::new(num);
- for (_, _, meta, _) in gen {
- index.find_by_sha256(&meta.sha256())?;
+ for (_, _, chunk) in gen {
+ index.find_by_sha256(&chunk.meta().sha256())?;
done += 1;
if done >= num {
return Ok(());
diff --git a/src/bin/benchmark-null.rs b/src/bin/benchmark-null.rs
index 259a837..fc60a77 100644
--- a/src/bin/benchmark-null.rs
+++ b/src/bin/benchmark-null.rs
@@ -23,5 +23,5 @@ fn main() {
let opt = Opt::from_args();
let gen = ChunkGenerator::new(opt.num);
- for (_, _, _, _) in gen {}
+ for (_, _, _) in gen {}
}
diff --git a/src/bin/benchmark-store.rs b/src/bin/benchmark-store.rs
index f7c82b1..7896f9d 100644
--- a/src/bin/benchmark-store.rs
+++ b/src/bin/benchmark-store.rs
@@ -20,8 +20,8 @@ fn main() -> anyhow::Result<()> {
let gen = ChunkGenerator::new(opt.num);
let store = Store::new(&opt.chunks);
- for (id, _, meta, chunk) in gen {
- store.save(&id, &meta, &chunk)?;
+ for (id, _, chunk) in gen {
+ store.save(&id, &&chunk)?;
}
Ok(())
diff --git a/src/bin/obnam-server.rs b/src/bin/obnam-server.rs
index 9a6540f..efee77e 100644
--- a/src/bin/obnam-server.rs
+++ b/src/bin/obnam-server.rs
@@ -109,9 +109,9 @@ pub async fn create_chunk(
}
};
- let chunk = DataChunk::new(data.to_vec());
+ let chunk = DataChunk::new(data.to_vec(), meta);
- let id = match store.save(&meta, &chunk) {
+ let id = match store.save(&chunk) {
Ok(id) => id,
Err(e) => {
error!("couldn't save: {}", e);
@@ -119,7 +119,7 @@ pub async fn create_chunk(
}
};
- info!("created chunk {}: {:?}", id, meta);
+ info!("created chunk {}", id);
Ok(ChunkResult::Created(id))
}