feat: don't panic if `Db::compact_chunks` with no matching chunks (#2818)

pull/24376/head
Raphael Taylor-Davies 2021-10-12 22:54:43 +01:00 committed by GitHub
parent 8a82f92c5d
commit f7f6965b65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -659,12 +659,16 @@ impl Db {
// Get a list of all the chunks to compact
let chunks = LockablePartition::chunks(&partition);
let partition = partition.upgrade();
let chunks = chunks
let chunks: Vec<_> = chunks
.iter()
.map(|chunk| chunk.write())
.filter(|chunk| predicate(&*chunk))
.collect();
if chunks.is_empty() {
return Ok(None);
}
let (_, fut) = lifecycle::compact_chunks(partition, chunks).context(LifecycleError)?;
fut
};