mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-07 21:42:56 +00:00
Merge file name and extension for index part files
This commit is contained in:
committed by
Kirill Bulatov
parent
827c3013bd
commit
8b28adb6a6
@@ -141,8 +141,7 @@ async fn download_index_part(
|
||||
sync_id: ZTenantTimelineId,
|
||||
) -> Result<IndexPart, DownloadError> {
|
||||
let index_part_path = metadata_path(conf, sync_id.timeline_id, sync_id.tenant_id)
|
||||
.with_file_name(IndexPart::FILE_NAME)
|
||||
.with_extension(IndexPart::FILE_EXTENSION);
|
||||
.with_file_name(IndexPart::FILE_NAME);
|
||||
let mut index_part_download = storage
|
||||
.download_storage_object(None, &index_part_path)
|
||||
.await?;
|
||||
@@ -663,8 +662,7 @@ mod tests {
|
||||
|
||||
let local_index_part_path =
|
||||
metadata_path(harness.conf, sync_id.timeline_id, sync_id.tenant_id)
|
||||
.with_file_name(IndexPart::FILE_NAME)
|
||||
.with_extension(IndexPart::FILE_EXTENSION);
|
||||
.with_file_name(IndexPart::FILE_NAME);
|
||||
let storage_path = local_storage.remote_object_id(&local_index_part_path)?;
|
||||
fs::create_dir_all(storage_path.parent().unwrap()).await?;
|
||||
fs::write(&storage_path, serde_json::to_vec(&index_part)?).await?;
|
||||
|
||||
@@ -278,8 +278,7 @@ pub struct IndexPart {
|
||||
}
|
||||
|
||||
impl IndexPart {
|
||||
pub const FILE_NAME: &'static str = "index_part";
|
||||
pub const FILE_EXTENSION: &'static str = "json";
|
||||
pub const FILE_NAME: &'static str = "index_part.json";
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn new(
|
||||
|
||||
@@ -42,8 +42,7 @@ pub(super) async fn upload_index_part(
|
||||
let index_part_bytes = tokio::io::BufReader::new(std::io::Cursor::new(index_part_bytes));
|
||||
|
||||
let index_part_path = metadata_path(conf, sync_id.timeline_id, sync_id.tenant_id)
|
||||
.with_file_name(IndexPart::FILE_NAME)
|
||||
.with_extension(IndexPart::FILE_EXTENSION);
|
||||
.with_file_name(IndexPart::FILE_NAME);
|
||||
storage
|
||||
.upload_storage_object(index_part_bytes, index_part_size, &index_part_path)
|
||||
.await
|
||||
@@ -442,17 +441,10 @@ mod tests {
|
||||
|
||||
let index_part_path = storage_files.first().unwrap();
|
||||
assert_eq!(
|
||||
index_part_path.file_stem().and_then(|name| name.to_str()),
|
||||
index_part_path.file_name().and_then(|name| name.to_str()),
|
||||
Some(IndexPart::FILE_NAME),
|
||||
"Remote index part should have the correct name"
|
||||
);
|
||||
assert_eq!(
|
||||
index_part_path
|
||||
.extension()
|
||||
.and_then(|extension| extension.to_str()),
|
||||
Some(IndexPart::FILE_EXTENSION),
|
||||
"Remote index part should have the correct extension"
|
||||
);
|
||||
|
||||
let remote_index_part: IndexPart =
|
||||
serde_json::from_slice(&fs::read(&index_part_path).await?)?;
|
||||
|
||||
Reference in New Issue
Block a user