mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-11 07:36:53 +00:00
refactor: move object option helper contracts (#3521)
This commit is contained in:
@@ -53,11 +53,13 @@ use rustfs_ecstore::rio::{DecryptReader, EncryptReader, HardLimitReader, boxed_r
|
||||
use rustfs_ecstore::rio::{HashReader, WritePlan};
|
||||
use rustfs_ecstore::set_disk::is_valid_storage_class;
|
||||
use rustfs_ecstore::store::ECStore;
|
||||
use rustfs_ecstore::store_api::{CompletePart, HTTPRangeSpec, ObjectIO, ObjectOptions, PutObjReader};
|
||||
use rustfs_ecstore::store_api::{HTTPRangeSpec, ObjectIO, ObjectOptions, PutObjReader};
|
||||
use rustfs_ecstore::store_api::{MultipartOperations, ObjectOperations};
|
||||
use rustfs_filemeta::{ReplicationStatusType, ReplicationType};
|
||||
use rustfs_s3_ops::S3Operation;
|
||||
use rustfs_storage_api::MultipartUploadResult;
|
||||
#[cfg(test)]
|
||||
use rustfs_storage_api::HTTPPreconditions;
|
||||
use rustfs_storage_api::{CompletePart, MultipartUploadResult};
|
||||
use rustfs_targets::EventName;
|
||||
use rustfs_utils::CompressionAlgorithm;
|
||||
use rustfs_utils::http::{
|
||||
@@ -146,6 +148,21 @@ fn normalize_complete_multipart_parts(parts: Vec<CompletePart>) -> S3Result<Vec<
|
||||
Ok(deduped_reversed)
|
||||
}
|
||||
|
||||
fn complete_part_from_s3(value: CompletedPart) -> CompletePart {
|
||||
CompletePart {
|
||||
part_num: value
|
||||
.part_number
|
||||
.and_then(|part_num| usize::try_from(part_num).ok())
|
||||
.unwrap_or_default(),
|
||||
etag: value.e_tag.map(|v| v.value().to_owned()),
|
||||
checksum_crc32: value.checksum_crc32,
|
||||
checksum_crc32c: value.checksum_crc32c,
|
||||
checksum_sha1: value.checksum_sha1,
|
||||
checksum_sha256: value.checksum_sha256,
|
||||
checksum_crc64nvme: value.checksum_crc64nvme,
|
||||
}
|
||||
}
|
||||
|
||||
async fn validate_table_catalog_object_mutation(bucket: &str, key: &str) -> S3Result<()> {
|
||||
table_catalog::validate_bucket_object_mutation(bucket, key)
|
||||
.await
|
||||
@@ -380,7 +397,7 @@ impl DefaultMultipartUsecase {
|
||||
.parts
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.map(CompletePart::from)
|
||||
.map(complete_part_from_s3)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let uploaded_parts = normalize_complete_multipart_parts(uploaded_parts_vec)?;
|
||||
@@ -1403,7 +1420,7 @@ mod tests {
|
||||
let opts = ObjectOptions {
|
||||
version_id: Some(Uuid::new_v4().to_string()),
|
||||
no_lock: true,
|
||||
http_preconditions: Some(rustfs_ecstore::store_api::HTTPPreconditions {
|
||||
http_preconditions: Some(HTTPPreconditions {
|
||||
if_none_match: Some("*".to_string()),
|
||||
if_match: Some("\"etag\"".to_string()),
|
||||
..Default::default()
|
||||
|
||||
@@ -93,6 +93,8 @@ use rustfs_notify::EventArgsBuilder;
|
||||
use rustfs_policy::policy::action::{Action, S3Action};
|
||||
use rustfs_s3_ops::{S3Operation, delete_event_name_for_marker, put_event_name_for_post_object};
|
||||
use rustfs_s3select_api::object_store::bytes_stream;
|
||||
#[cfg(test)]
|
||||
use rustfs_storage_api::HTTPPreconditions;
|
||||
use rustfs_targets::{
|
||||
EventName, extract_params_header, extract_resp_elements, get_request_host, get_request_port, get_request_user_agent,
|
||||
};
|
||||
@@ -4897,7 +4899,7 @@ mod tests {
|
||||
let opts = ObjectOptions {
|
||||
version_id: Some(version_id.clone()),
|
||||
no_lock: true,
|
||||
http_preconditions: Some(rustfs_ecstore::store_api::HTTPPreconditions {
|
||||
http_preconditions: Some(HTTPPreconditions {
|
||||
if_none_match: Some("\"etag\"".to_string()),
|
||||
if_match: Some("\"other\"".to_string()),
|
||||
..Default::default()
|
||||
|
||||
@@ -40,11 +40,11 @@ use rustfs_ecstore::{
|
||||
versioning_sys::BucketVersioningSys,
|
||||
},
|
||||
error::{StorageError, is_err_bucket_not_found, is_err_object_not_found, is_err_version_not_found},
|
||||
store_api::{ObjectLockRetentionOptions, ObjectOperations, ObjectOptions},
|
||||
store_api::{ObjectOperations, ObjectOptions},
|
||||
};
|
||||
use rustfs_io_metrics::record_s3_op;
|
||||
use rustfs_s3_ops::S3Operation;
|
||||
use rustfs_storage_api::{BucketOperations, BucketOptions};
|
||||
use rustfs_storage_api::{BucketOperations, BucketOptions, ObjectLockRetentionOptions};
|
||||
use rustfs_targets::EventName;
|
||||
use rustfs_utils::http::headers::{
|
||||
AMZ_OBJECT_LOCK_LEGAL_HOLD_LOWER, AMZ_OBJECT_LOCK_MODE_LOWER, AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE_LOWER,
|
||||
|
||||
@@ -31,8 +31,9 @@ use s3s::header::X_AMZ_OBJECT_LOCK_RETAIN_UNTIL_DATE;
|
||||
|
||||
use crate::auth::UNSIGNED_PAYLOAD;
|
||||
use crate::auth::UNSIGNED_PAYLOAD_TRAILER;
|
||||
use rustfs_ecstore::store_api::{HTTPPreconditions, HTTPRangeSpec, ObjectOptions};
|
||||
use rustfs_ecstore::store_api::{HTTPRangeSpec, ObjectOptions};
|
||||
use rustfs_policy::service_type::ServiceType;
|
||||
use rustfs_storage_api::HTTPPreconditions;
|
||||
use rustfs_utils::hash::EMPTY_STRING_SHA256_HASH;
|
||||
use rustfs_utils::http::AMZ_CONTENT_SHA256;
|
||||
use rustfs_utils::path::is_dir_object;
|
||||
|
||||
@@ -45,8 +45,9 @@ use rustfs_ecstore::disk::RUSTFS_META_BUCKET;
|
||||
use rustfs_ecstore::error::StorageError;
|
||||
use rustfs_ecstore::{
|
||||
set_disk::get_lock_acquire_timeout,
|
||||
store_api::{HTTPPreconditions, ListOperations, NamespaceLocking, ObjectIO, ObjectOperations, ObjectOptions, PutObjReader},
|
||||
store_api::{ListOperations, NamespaceLocking, ObjectIO, ObjectOperations, ObjectOptions, PutObjReader},
|
||||
};
|
||||
use rustfs_storage_api::HTTPPreconditions;
|
||||
use serde::{Deserialize, Serialize, de::DeserializeOwned};
|
||||
use time::{Duration, OffsetDateTime};
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
Reference in New Issue
Block a user