Skip to content

Commit

Permalink
Address PR's feedbacks
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Isaev <iisaev@amazon.com>
  • Loading branch information
Ilya Isaev committed Jan 15, 2025
1 parent 422c407 commit 9c1b3d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 7 additions & 5 deletions mountpoint-s3-client/src/s3_crt_client/copy_object.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::object_client::{CopyObjectError, CopyObjectParams, CopyObjectResult, ObjectClientResult};
use crate::s3_crt_client::{ConstructionError, S3CrtClient, S3CrtClientInner, S3Operation, S3RequestError};
use mountpoint_s3_crt::{http::request_response::Header, s3::client::MetaRequestResult};
use std::ops::Deref;
use std::os::unix::prelude::OsStrExt;

use mountpoint_s3_crt::{http::request_response::Header, s3::client::MetaRequestResult};

use crate::object_client::{CopyObjectError, CopyObjectParams, CopyObjectResult, ObjectClientResult};
use crate::s3_crt_client::{S3CrtClient, S3CrtClientInner, S3Operation, S3RequestError};
use tracing::trace;

impl S3CrtClient {
Expand Down Expand Up @@ -44,9 +46,9 @@ impl S3CrtClient {
.inner
.endpoint_config
.resolve_for_bucket(source_bucket)
.map_err(|e| S3RequestError::from(ConstructionError::from(e)))?
.map_err(S3RequestError::construction_failure)?
.uri()
.map_err(|e| S3RequestError::from(ConstructionError::from(e)))?;
.map_err(S3RequestError::construction_failure)?;
let source_uri = format!("{}/{source_key}", uri.as_os_str().to_string_lossy());
trace!(source_uri, "resolved source uri");
options.copy_source_uri(source_uri);
Expand Down
18 changes: 8 additions & 10 deletions mountpoint-s3-crt/src/s3/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ struct MetaRequestOptionsInner<'a> {
/// Owned checksum config, if provided.
checksum_config: Option<ChecksumConfig>,

/// Owned source uri for copy request, if provided.
copy_source_uri: Option<String>,

/// Telemetry callback, if provided
on_telemetry: Option<TelemetryCallback>,

Expand All @@ -258,9 +261,6 @@ struct MetaRequestOptionsInner<'a> {

/// Pin this struct because inner.user_data will be a pointer to this object.
_pinned: PhantomPinned,

/// Owned source uri for copy request, if provided.
store_copy_source_uri: Option<String>,
}

impl<'a> MetaRequestOptionsInner<'a> {
Expand Down Expand Up @@ -329,7 +329,7 @@ impl<'a> MetaRequestOptions<'a> {
on_upload_review: None,
on_finish: None,
_pinned: Default::default(),
store_copy_source_uri: None,
copy_source_uri: None,
});

// Pin the options in-place. This is because it's about to become self-referential.
Expand Down Expand Up @@ -471,12 +471,10 @@ impl<'a> MetaRequestOptions<'a> {
pub fn copy_source_uri(&mut self, source_uri: String) -> &mut Self {
// SAFETY: we aren't moving out of the struct.
let options = unsafe { Pin::get_unchecked_mut(Pin::as_mut(&mut self.0)) };
options.store_copy_source_uri = Some(source_uri);
if let Some(uri) = &options.store_copy_source_uri {
// SAFETY: We ensure that the cursor points to data that lives
// as long as the options struct
options.inner.copy_source_uri = unsafe { uri.as_aws_byte_cursor() };
}
options.copy_source_uri = Some(source_uri);
// SAFETY: We ensure that the cursor points to data that lives
// as long as the options struct
options.inner.copy_source_uri = unsafe { options.copy_source_uri.as_mut().unwrap().as_aws_byte_cursor() };
self
}
}
Expand Down

0 comments on commit 9c1b3d5

Please sign in to comment.