aboutsummaryrefslogtreecommitdiff
path: root/src/block
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-05-09 12:40:08 +0200
committerAlex Auvolat <alex@adnab.me>2023-05-09 12:40:08 +0200
commit351d734e6c035a6f22f9fe0d62a783a81a134f45 (patch)
treeded5a11616d5147ed254bba2974d3591fb1e041f /src/block
parenta1fcf1b175cc11b4e797d81ea483538813732d6d (diff)
parentb925f53dc3b0bae77aa3f73e581faace2eb3b21a (diff)
downloadgarage-351d734e6c035a6f22f9fe0d62a783a81a134f45.tar.gz
garage-351d734e6c035a6f22f9fe0d62a783a81a134f45.zip
Merge branch 'main' into next
Diffstat (limited to 'src/block')
-rw-r--r--src/block/Cargo.toml8
-rw-r--r--src/block/manager.rs30
2 files changed, 29 insertions, 9 deletions
diff --git a/src/block/Cargo.toml b/src/block/Cargo.toml
index c6985754..3bf1c40a 100644
--- a/src/block/Cargo.toml
+++ b/src/block/Cargo.toml
@@ -14,10 +14,10 @@ path = "lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-garage_db = { version = "0.8.2", path = "../db" }
-garage_rpc = { version = "0.8.2", path = "../rpc" }
-garage_util = { version = "0.8.2", path = "../util" }
-garage_table = { version = "0.8.2", path = "../table" }
+garage_db.workspace = true
+garage_rpc.workspace = true
+garage_util.workspace = true
+garage_table.workspace = true
opentelemetry = "0.17"
diff --git a/src/block/manager.rs b/src/block/manager.rs
index 26278974..3ece9a8a 100644
--- a/src/block/manager.rs
+++ b/src/block/manager.rs
@@ -600,12 +600,32 @@ impl BlockManager {
/// Utility: check if block is stored compressed. Error if block is not stored
async fn is_block_compressed(&self, hash: &Hash) -> Result<bool, Error> {
let mut path = self.block_path(hash);
- path.set_extension("zst");
- if fs::metadata(&path).await.is_ok() {
- return Ok(true);
+
+ // 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);
+ }
+
+ 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() {
+ return Ok(true);
+ }
+
+ path.set_extension("");
+
+ fs::metadata(&path).await.map(|_| false).map_err(Into::into)
+ }
}
- path.set_extension("");
- fs::metadata(&path).await.map(|_| false).map_err(Into::into)
}
async fn lock_mutate(&self, hash: &Hash) -> MutexGuard<'_, BlockManagerLocked> {