feat: add metadata method to puffin reader (#5501)

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
This commit is contained in:
Zhenchi
2025-02-10 17:14:54 +08:00
committed by GitHub
parent c19ecd7ea2
commit 5be81abba3
2 changed files with 14 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ pub mod stager;
mod tests;
use std::path::PathBuf;
use std::sync::Arc;
use async_trait::async_trait;
use common_base::range_read::RangeReader;
@@ -28,6 +29,7 @@ use futures::AsyncRead;
use crate::blob_metadata::CompressionCodec;
use crate::error::Result;
use crate::file_metadata::FileMetadata;
/// The `PuffinManager` trait provides a unified interface for creating `PuffinReader` and `PuffinWriter`.
#[async_trait]
@@ -79,6 +81,9 @@ pub trait PuffinReader {
fn with_file_size_hint(self, file_size_hint: Option<u64>) -> Self;
/// Returns the metadata of the Puffin file.
async fn metadata(&self) -> Result<Arc<FileMetadata>>;
/// Reads a blob from the Puffin file.
///
/// The returned `BlobGuard` is used to access the blob data.

View File

@@ -87,6 +87,15 @@ where
self
}
async fn metadata(&self) -> Result<Arc<FileMetadata>> {
let reader = self
.puffin_file_accessor
.reader(&self.puffin_file_name)
.await?;
let mut file = PuffinFileReader::new(reader);
self.get_puffin_file_metadata(&mut file).await
}
async fn blob(&self, key: &str) -> Result<Self::Blob> {
let mut reader = self
.puffin_file_accessor