Skip to content

Commit f95edd1

Browse files
authored
Fix minor test bug. (#49)
AsyncInMemoryStorage has a bug in compaction where the first entry is not able to be compacted. This would not normally be caught, but there's a bug in repo.rs where compaction doesn't happen, and I'm trying to track that down.
1 parent 7b6a698 commit f95edd1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/fs_store.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl FsStore {
8686
pub fn get(&self, id: &DocumentId) -> Result<Option<Vec<u8>>, Error> {
8787
let chunks = Chunks::load(&self.root, id)?;
8888
let Some(chunks) = chunks else {
89-
return Ok(None)
89+
return Ok(None);
9090
};
9191
let mut result = Vec::new();
9292
result.extend(chunks.snapshots.into_values().flatten());
@@ -163,7 +163,7 @@ impl FsStore {
163163
// Load all the data we have into a doc
164164
let Some(chunks) = Chunks::load(&self.root, id)? else {
165165
tracing::warn!(doc_id=%id, "attempted to compact non-existent document");
166-
return Ok(())
166+
return Ok(());
167167
};
168168
let mut doc = chunks
169169
.to_doc()
@@ -382,7 +382,8 @@ impl Chunks {
382382
tracing::warn!(bad_file=%path.display(), "unexpected non-file in level2 path");
383383
continue;
384384
}
385-
let Some(chunk_name) = entry.file_name().to_str().and_then(SavedChunkName::parse) else {
385+
let Some(chunk_name) = entry.file_name().to_str().and_then(SavedChunkName::parse)
386+
else {
386387
tracing::warn!(bad_file=%path.display(), "unexpected non-chunk file in level2 path");
387388
continue;
388389
};

test_utils/src/storage_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ impl AsyncInMemoryStorage {
136136
StorageRequest::Compact(doc_id, data, sender) => {
137137
let _entry = documents
138138
.entry(doc_id)
139-
.and_modify(|entry| *entry = data)
140-
.or_insert_with(Default::default);
139+
.and_modify(|entry| *entry = data.clone())
140+
.or_insert_with(|| data);
141141
let (tx, rx) = oneshot();
142142
results.push_back(tx);
143143
tokio::spawn(async move {

0 commit comments

Comments
 (0)