mirror of
https://github.com/neondatabase/neon.git
synced 2026-06-04 22:10:39 +00:00
Also support the generation-less legacy naming scheme
This commit is contained in:
@@ -312,17 +312,24 @@ pub(crate) async fn main(cmd: &LayerCmd) -> Result<()> {
|
||||
let Some(file_name) = file_key.object_name() else {
|
||||
continue;
|
||||
};
|
||||
// Split off the final part. Sometimes this cuts off actually important pieces in case of legacy layer files, but usually it doesn't.
|
||||
let Some(file_without_generation) = file_name.rsplit_once('-') else {
|
||||
continue;
|
||||
};
|
||||
let Ok(LayerName::Image(_layer_file_name)) =
|
||||
LayerName::from_str(file_without_generation.0)
|
||||
else {
|
||||
// Skipping because it's either not a layer or an image layer
|
||||
//println!("object {file_name}: not an image layer");
|
||||
continue;
|
||||
};
|
||||
match LayerName::from_str(file_name) {
|
||||
Ok(LayerName::Delta(_)) => continue,
|
||||
Ok(LayerName::Image(_)) => (),
|
||||
Err(_e) => {
|
||||
// Split off the final part. We ensured above that this is not turning a
|
||||
// generation-less delta layer file name into an image layer file name.
|
||||
let Some(file_without_generation) = file_name.rsplit_once('-') else {
|
||||
continue;
|
||||
};
|
||||
let Ok(LayerName::Image(_layer_file_name)) =
|
||||
LayerName::from_str(file_without_generation.0)
|
||||
else {
|
||||
// Skipping because it's either not a layer or an image layer
|
||||
//println!("object {file_name}: not an image layer");
|
||||
continue;
|
||||
};
|
||||
}
|
||||
}
|
||||
let json_file_path = layers_dir.join(format!("{file_name}.json"));
|
||||
if tokio::fs::try_exists(&json_file_path).await? {
|
||||
//println!("object {file_name}: report already created");
|
||||
|
||||
@@ -269,20 +269,19 @@ impl<const BUFFERED: bool> BlobWriter<BUFFERED> {
|
||||
use ImageCompressionAlgorithm::*;
|
||||
let (high_bit_mask, len_written, srcbuf) = match algorithm {
|
||||
Some(ZstdLow | Zstd | ZstdHigh) => {
|
||||
let mut encoder =
|
||||
if matches!(algorithm, Some(ZstdLow)) {
|
||||
async_compression::tokio::write::ZstdEncoder::with_quality(
|
||||
Vec::new(),
|
||||
Level::Precise(1),
|
||||
)
|
||||
} else if matches!(algorithm, Some(ZstdHigh)) {
|
||||
async_compression::tokio::write::ZstdEncoder::with_quality(
|
||||
Vec::new(),
|
||||
Level::Precise(6),
|
||||
)
|
||||
} else {
|
||||
async_compression::tokio::write::ZstdEncoder::new(Vec::new())
|
||||
};
|
||||
let mut encoder = if matches!(algorithm, Some(ZstdLow)) {
|
||||
async_compression::tokio::write::ZstdEncoder::with_quality(
|
||||
Vec::new(),
|
||||
Level::Precise(1),
|
||||
)
|
||||
} else if matches!(algorithm, Some(ZstdHigh)) {
|
||||
async_compression::tokio::write::ZstdEncoder::with_quality(
|
||||
Vec::new(),
|
||||
Level::Precise(6),
|
||||
)
|
||||
} else {
|
||||
async_compression::tokio::write::ZstdEncoder::new(Vec::new())
|
||||
};
|
||||
let slice = srcbuf.slice(..);
|
||||
encoder.write_all(&slice[..]).await.unwrap();
|
||||
encoder.flush().await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user