change extention for compressed files

set_extension don't behave verywell with extensions containing multiple dots
This commit is contained in:
Trinity Pointard 2021-04-06 20:50:03 +02:00
parent e4b66a9e28
commit 4d5263ccf3

View File

@ -174,7 +174,7 @@ impl BlockManager {
fs::create_dir_all(&path).await?;
path.push(hex::encode(hash));
if checksum.is_some() {
path.set_extension("zst.b2");
path.set_extension("zst_b2");
}
let mut f = fs::File::create(path).await?;
@ -198,7 +198,7 @@ impl BlockManager {
f.map(|f| (f, false)).map_err(Into::into)
}
Ok(true) => {
path.set_extension("zst.b2");
path.set_extension("zst_b2");
let f = fs::File::open(&path).await;
f.map(|f| (f, true)).map_err(Into::into)
}
@ -270,7 +270,7 @@ impl BlockManager {
async fn is_block_compressed(&self, hash: &Hash) -> Result<bool, Error> {
let mut path = self.block_path(hash);
path.set_extension("zst.b2");
path.set_extension("zst_b2");
if fs::metadata(&path).await.is_ok() {
return Ok(true);
}