diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-01-09 16:52:35 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-01-10 18:17:27 +0200 |
commit | e5f68184bfe91f6874fe8c2344dbd5fa613d6bee (patch) | |
tree | 9860e2bc6c827bf69d1c324303e01c86efd94e65 /src/store.rs | |
parent | 7ff248232a414b907b3abe464cc015e5ea48c236 (diff) | |
download | obnam2-e5f68184bfe91f6874fe8c2344dbd5fa613d6bee.tar.gz |
feat! use SQLite db for chunk index on server
This speeds startup a lot. However, the backup repository needs to be
re-created from scratch and internal APIs have change in incompatible
ways.
Diffstat (limited to 'src/store.rs')
-rw-r--r-- | src/store.rs | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/src/store.rs b/src/store.rs index 123b9fa..e6cc71f 100644 --- a/src/store.rs +++ b/src/store.rs @@ -53,20 +53,12 @@ impl Store { Ok(()) } - /// Load a chunk's metadata from a store. - pub fn load_meta(&self, id: &ChunkId) -> anyhow::Result<ChunkMeta> { - let (_, metaname, _) = &self.filenames(id); - let meta = std::fs::read(&metaname)?; - Ok(serde_json::from_slice(&meta)?) - } - /// Load a chunk from a store. - pub fn load(&self, id: &ChunkId) -> anyhow::Result<LoadedChunk> { + pub fn load(&self, id: &ChunkId) -> anyhow::Result<DataChunk> { let (_, _, dataname) = &self.filenames(id); - let meta = self.load_meta(id)?; let data = std::fs::read(&dataname)?; let data = DataChunk::new(data); - Ok(LoadedChunk { meta, data }) + Ok(data) } /// Delete a chunk from a store. @@ -77,22 +69,3 @@ impl Store { Ok(()) } } - -pub struct LoadedChunk { - meta: ChunkMeta, - data: DataChunk, -} - -impl LoadedChunk { - pub fn new(meta: ChunkMeta, data: DataChunk) -> Self { - Self { meta, data } - } - - pub fn meta(&self) -> &ChunkMeta { - &self.meta - } - - pub fn data(&self) -> &DataChunk { - &self.data - } -} |