mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-07 13:53:12 +00:00
refactor: move HTTP range helper contracts (#3533)
This commit is contained in:
@@ -53,13 +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::{HTTPRangeSpec, ObjectIO, ObjectOptions, PutObjReader};
|
||||
use rustfs_ecstore::store_api::{MultipartOperations, ObjectOperations};
|
||||
use rustfs_ecstore::store_api::{ObjectIO, ObjectOptions, PutObjReader};
|
||||
use rustfs_filemeta::{ReplicationStatusType, ReplicationType};
|
||||
use rustfs_s3_ops::S3Operation;
|
||||
#[cfg(test)]
|
||||
use rustfs_storage_api::HTTPPreconditions;
|
||||
use rustfs_storage_api::{CompletePart, MultipartUploadResult};
|
||||
use rustfs_storage_api::{CompletePart, HTTPRangeSpec, MultipartUploadResult};
|
||||
use rustfs_targets::EventName;
|
||||
use rustfs_utils::CompressionAlgorithm;
|
||||
use rustfs_utils::http::{
|
||||
|
||||
@@ -79,7 +79,7 @@ use rustfs_ecstore::rio::{DynReader, HashReader, WritePlan, wrap_reader};
|
||||
use rustfs_ecstore::set_disk::{get_lock_acquire_timeout, is_valid_storage_class};
|
||||
use rustfs_ecstore::store::ECStore;
|
||||
use rustfs_ecstore::store_api::{
|
||||
HTTPRangeSpec, NamespaceLocking, ObjectIO, ObjectInfo, ObjectOperations, ObjectOptions, ObjectToDelete, PutObjReader,
|
||||
NamespaceLocking, ObjectIO, ObjectInfo, ObjectOperations, ObjectOptions, ObjectToDelete, PutObjReader,
|
||||
};
|
||||
use rustfs_filemeta::{
|
||||
REPLICATE_INCOMING_DELETE, ReplicateDecision, ReplicateTargetDecision, ReplicationState, ReplicationStatusType,
|
||||
@@ -95,6 +95,7 @@ use rustfs_s3_ops::{S3Operation, delete_event_name_for_marker, put_event_name_fo
|
||||
use rustfs_s3select_api::object_store::bytes_stream;
|
||||
#[cfg(test)]
|
||||
use rustfs_storage_api::HTTPPreconditions;
|
||||
use rustfs_storage_api::HTTPRangeSpec;
|
||||
use rustfs_targets::{
|
||||
EventName, extract_params_header, extract_resp_elements, get_request_host, get_request_port, get_request_user_agent,
|
||||
};
|
||||
@@ -1585,7 +1586,17 @@ impl DefaultObjectUsecase {
|
||||
if let Some(part_number) = part_number
|
||||
&& rs.is_none()
|
||||
{
|
||||
rs = HTTPRangeSpec::from_object_info(&info, part_number);
|
||||
rs = HTTPRangeSpec::from_part_sizes(
|
||||
info.size,
|
||||
part_number,
|
||||
info.parts.iter().map(|part| {
|
||||
if part.actual_size > 0 {
|
||||
part.actual_size
|
||||
} else {
|
||||
i64::try_from(part.size).unwrap_or(i64::MAX)
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
validate_sse_headers_for_read(&info.user_defined, &req.headers)?;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
use rustfs_ecstore::bucket::quota::QuotaError;
|
||||
use rustfs_ecstore::error::StorageError;
|
||||
use rustfs_storage_api::HTTPRangeError;
|
||||
use s3s::{S3Error, S3ErrorCode};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -282,6 +283,16 @@ impl From<StorageError> for ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<HTTPRangeError> for ApiError {
|
||||
fn from(err: HTTPRangeError) -> Self {
|
||||
ApiError {
|
||||
code: S3ErrorCode::InvalidRange,
|
||||
message: err.to_string(),
|
||||
source: Some(Box::new(err)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for ApiError {
|
||||
fn from(err: std::io::Error) -> Self {
|
||||
// Check if the error is a ChecksumMismatch (BadDigest)
|
||||
|
||||
@@ -31,9 +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::{HTTPRangeSpec, ObjectOptions};
|
||||
use rustfs_ecstore::store_api::ObjectOptions;
|
||||
use rustfs_policy::service_type::ServiceType;
|
||||
use rustfs_storage_api::HTTPPreconditions;
|
||||
use rustfs_storage_api::{HTTPPreconditions, HTTPRangeSpec};
|
||||
use rustfs_utils::hash::EMPTY_STRING_SHA256_HASH;
|
||||
use rustfs_utils::http::AMZ_CONTENT_SHA256;
|
||||
use rustfs_utils::path::is_dir_object;
|
||||
|
||||
Reference in New Issue
Block a user