block/manager.rs: Prioritize raw blocks when no compression configured #566
1 changed files with 25 additions and 5 deletions
|
@ -600,13 +600,33 @@ impl BlockManager {
|
||||||
/// Utility: check if block is stored compressed. Error if block is not stored
|
/// Utility: check if block is stored compressed. Error if block is not stored
|
||||||
async fn is_block_compressed(&self, hash: &Hash) -> Result<bool, Error> {
|
async fn is_block_compressed(&self, hash: &Hash) -> Result<bool, Error> {
|
||||||
let mut path = self.block_path(hash);
|
let mut path = self.block_path(hash);
|
||||||
|
|
||||||
|
// If compression is disabled on node - check for the raw block
|
||||||
|
// first and then a compressed one (as compression may have been
|
||||||
|
// previously enabled).
|
||||||
|
match self.compression_level {
|
||||||
|
None => {
|
||||||
|
if fs::metadata(&path).await.is_ok() {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
jpds marked this conversation as resolved
Outdated
|
|||||||
path.set_extension("zst");
|
path.set_extension("zst");
|
||||||
|
|
||||||
|
fs::metadata(&path).await.map(|_| true).map_err(Into::into)
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
path.set_extension("zst");
|
||||||
|
|
||||||
if fs::metadata(&path).await.is_ok() {
|
if fs::metadata(&path).await.is_ok() {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
path.set_extension("");
|
path.set_extension("");
|
||||||
|
|
||||||
fs::metadata(&path).await.map(|_| false).map_err(Into::into)
|
fs::metadata(&path).await.map(|_| false).map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn lock_mutate(&self, hash: &Hash) -> MutexGuard<'_, BlockManagerLocked> {
|
async fn lock_mutate(&self, hash: &Hash) -> MutexGuard<'_, BlockManagerLocked> {
|
||||||
let tracer = opentelemetry::global::tracer("garage");
|
let tracer = opentelemetry::global::tracer("garage");
|
||||||
|
|
Loading…
Reference in a new issue
The true/false values returned also need to be swapped in the case we are checking the non-compressed file first.