merge fix/224

This commit is contained in:
weisd
2025-02-24 23:05:16 +08:00
7 changed files with 31 additions and 19 deletions
+2 -4
View File
@@ -19,7 +19,7 @@ use crate::disk::error::{
use crate::disk::os::{check_path_length, is_empty_dir};
use crate::disk::{LocalFileReader, LocalFileWriter, STORAGE_FORMAT_FILE};
use crate::error::{Error, Result};
use crate::file_meta::read_xl_meta_no_data;
use crate::file_meta::{get_file_info, read_xl_meta_no_data, FileInfoOpts};
use crate::global::{GLOBAL_IsErasureSD, GLOBAL_RootDiskThreshold};
use crate::heal::data_scanner::{has_active_rules, scan_data_folder, ScannerItem, ShouldSleepFn, SizeSummary};
use crate::heal::data_scanner_metric::{ScannerMetric, ScannerMetrics};
@@ -1995,10 +1995,8 @@ impl DiskAPI for LocalDisk {
let (data, _) = self.read_raw(volume, file_dir, file_path, read_data).await?;
let mut meta = FileMeta::default();
meta.unmarshal_msg(&data)?;
let fi = get_file_info(&data, volume, path, version_id, FileInfoOpts { data: read_data }).await?;
let fi = meta.into_fileinfo(volume, path, version_id, read_data, true)?;
Ok(fi)
}
async fn read_xl(&self, volume: &str, path: &str, read_data: bool) -> Result<RawFileInfo> {
+2 -1
View File
@@ -1208,8 +1208,9 @@ pub struct VolumeInfo {
pub created: Option<OffsetDateTime>,
}
#[derive(Deserialize, Serialize, Debug)]
#[derive(Deserialize, Serialize, Debug, Default)]
pub struct ReadOptions {
pub incl_free_versions: bool,
pub read_data: bool,
pub healing: bool,
}
+4 -3
View File
@@ -554,7 +554,7 @@ impl FileMeta {
let header = &ver.header;
if let Some(vid) = has_vid {
if header.version_id == Some(vid) {
if header.version_id != Some(vid) {
is_latest = false;
succ_mod_time = header.mod_time;
continue;
@@ -2045,7 +2045,7 @@ pub struct FileInfoOpts {
pub data: bool,
}
async fn get_file_info(buf: &[u8], volume: &str, path: &str, version_id: &str, opts: FileInfoOpts) -> Result<FileInfo> {
pub async fn get_file_info(buf: &[u8], volume: &str, path: &str, version_id: &str, opts: FileInfoOpts) -> Result<FileInfo> {
let vid = {
if version_id.is_empty() {
None
@@ -2067,8 +2067,9 @@ async fn get_file_info(buf: &[u8], volume: &str, path: &str, version_id: &str, o
});
}
warn!("get_file_info vid {:?}", &vid);
let fi = meta.into_fileinfo(volume, path, version_id, opts.data, true)?;
warn!("get_file_info {:?}", &fi);
Ok(fi)
}
+6 -2
View File
@@ -1088,7 +1088,11 @@ impl SetDisks {
let mut errors = Vec::with_capacity(disks.len());
for disk in disks.iter() {
let opts = ReadOptions { read_data, healing };
let opts = ReadOptions {
read_data,
healing,
..Default::default()
};
futures.push(async move {
if let Some(disk) = disk {
if version_id.is_empty() {
@@ -3634,7 +3638,7 @@ impl ObjectIO for SetDisks {
Ok(reader)
}
#[tracing::instrument(level = "debug", skip(self, data))]
#[tracing::instrument(level = "debug", skip(self, data,))]
async fn put_object(&self, bucket: &str, object: &str, data: &mut PutObjReader, opts: &ObjectOptions) -> Result<ObjectInfo> {
let disks = self.disks.read().await;