Skip to content

Commit

Permalink
Remove Transfer from FailedDownloadTransfer and `FailedUploadTran…
Browse files Browse the repository at this point in the history
…sfer`
  • Loading branch information
ysaito1001 committed Nov 11, 2024
1 parent 16a021c commit f500116
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 28 deletions.
4 changes: 2 additions & 2 deletions aws-s3-transfer-manager/src/operation/download_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::sync::{Arc, Mutex};
use tokio::task::JoinSet;
use tracing::Instrument;

use crate::types::FailedDownloadTransfer;
use crate::types::FailedDownload;

use super::{validate_target_is_dir, TransferContext};

Expand Down Expand Up @@ -81,7 +81,7 @@ pub(crate) struct DownloadObjectsState {
// TODO - Determine if `input` should be separated from this struct
// https://github.com/awslabs/aws-s3-transfer-manager-rs/pull/67#discussion_r1821661603
input: DownloadObjectsInput,
failed_downloads: Mutex<Vec<FailedDownloadTransfer>>,
failed_downloads: Mutex<Vec<FailedDownload>>,
successful_downloads: AtomicU64,
total_bytes_transferred: AtomicU64,
}
Expand Down
14 changes: 7 additions & 7 deletions aws-s3-transfer-manager/src/operation/download_objects/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

use super::DownloadObjectsState;
use crate::types::FailedDownloadTransfer;
use crate::types::FailedDownload;
use std::sync::atomic::Ordering;

/// Output type for downloading multiple objects
Expand All @@ -15,7 +15,7 @@ pub struct DownloadObjectsOutput {
pub objects_downloaded: u64,

/// A list of failed object transfers
pub failed_transfers: Vec<FailedDownloadTransfer>,
pub failed_transfers: Vec<FailedDownload>,

// FIXME - likely remove when progress is implemented?
/// Total number of bytes transferred
Expand All @@ -34,7 +34,7 @@ impl DownloadObjectsOutput {
}

/// A slice of failed object transfers
pub fn failed_transfers(&self) -> &[FailedDownloadTransfer] {
pub fn failed_transfers(&self) -> &[FailedDownload] {
self.failed_transfers.as_slice()
}

Expand Down Expand Up @@ -63,7 +63,7 @@ impl From<&DownloadObjectsState> for DownloadObjectsOutput {
#[derive(Debug, Default)]
pub struct DownloadObjectsOutputBuilder {
pub(crate) objects_downloaded: u64,
pub(crate) failed_transfers: Vec<FailedDownloadTransfer>,
pub(crate) failed_transfers: Vec<FailedDownload>,
pub(crate) total_bytes_transferred: u64,
}

Expand All @@ -83,19 +83,19 @@ impl DownloadObjectsOutputBuilder {
///
/// To override the contents of this collection use
/// [`set_failed_transfers`](Self::set_failed_transfers)
pub fn failed_transfers(mut self, input: FailedDownloadTransfer) -> Self {
pub fn failed_transfers(mut self, input: FailedDownload) -> Self {
self.failed_transfers.push(input);
self
}

/// Set a list of failed object transfers
pub fn set_failed_transfers(mut self, input: Vec<FailedDownloadTransfer>) -> Self {
pub fn set_failed_transfers(mut self, input: Vec<FailedDownload>) -> Self {
self.failed_transfers = input;
self
}

/// Get a list of failed object transfers
pub fn get_failed_transfers(&self) -> &[FailedDownloadTransfer] {
pub fn get_failed_transfers(&self) -> &[FailedDownload] {
self.failed_transfers.as_slice()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::error;
use crate::operation::download::body::Body;
use crate::operation::download::{DownloadInput, DownloadInputBuilder};
use crate::operation::DEFAULT_DELIMITER;
use crate::types::{DownloadFilter, FailedDownloadTransfer, FailedTransferPolicy};
use crate::types::{DownloadFilter, FailedDownload, FailedTransferPolicy};

use super::list_objects::ListObjectsStream;
use super::DownloadObjectsContext;
Expand Down Expand Up @@ -113,7 +113,7 @@ pub(super) async fn download_objects(
FailedTransferPolicy::Continue => {
let mut failures = ctx.state.failed_downloads.lock().unwrap();

let failed_transfer = FailedDownloadTransfer {
let failed_transfer = FailedDownload {
input: job.input(&ctx),
error: err,
};
Expand Down
4 changes: 2 additions & 2 deletions aws-s3-transfer-manager/src/operation/upload_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tracing::Instrument;

mod worker;

use crate::types::FailedUploadTransfer;
use crate::types::FailedUpload;

use super::{validate_target_is_dir, TransferContext};

Expand Down Expand Up @@ -69,7 +69,7 @@ pub(crate) struct UploadObjectsState {
// TODO - Determine if `input` should be separated from this struct
// https://github.com/awslabs/aws-s3-transfer-manager-rs/pull/67#discussion_r1821661603
input: UploadObjectsInput,
failed_uploads: Mutex<Vec<FailedUploadTransfer>>,
failed_uploads: Mutex<Vec<FailedUpload>>,
successful_uploads: AtomicU64,
total_bytes_transferred: AtomicU64,
}
Expand Down
12 changes: 6 additions & 6 deletions aws-s3-transfer-manager/src/operation/upload_objects/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

use super::UploadObjectsState;
use crate::types::FailedUploadTransfer;
use crate::types::FailedUpload;
use std::sync::atomic::Ordering;

/// Output type for uploading multiple objects
Expand All @@ -15,7 +15,7 @@ pub struct UploadObjectsOutput {
objects_uploaded: u64,

/// The list of failed uploads
failed_transfers: Vec<FailedUploadTransfer>,
failed_transfers: Vec<FailedUpload>,

// FIXME - likely remove when progress is implemented (let's be consistent with downloads for now)?
/// Total number of bytes transferred
Expand All @@ -34,7 +34,7 @@ impl UploadObjectsOutput {
}

/// The list of failed uploads
pub fn failed_transfers(&self) -> &[FailedUploadTransfer] {
pub fn failed_transfers(&self) -> &[FailedUpload] {
self.failed_transfers.as_slice()
}

Expand Down Expand Up @@ -63,7 +63,7 @@ impl From<&UploadObjectsState> for UploadObjectsOutput {
#[derive(Debug, Default)]
pub struct UploadObjectsOutputBuilder {
pub(crate) objects_uploaded: u64,
pub(crate) failed_transfers: Vec<FailedUploadTransfer>,
pub(crate) failed_transfers: Vec<FailedUpload>,
pub(crate) total_bytes_transferred: u64,
}

Expand All @@ -82,13 +82,13 @@ impl UploadObjectsOutputBuilder {
/// Append a failed transfer.
///
/// To override the contents of this collection use [`set_failed_transfers`](Self::set_failed_transfers)
pub fn failed_transfers(mut self, input: FailedUploadTransfer) -> Self {
pub fn failed_transfers(mut self, input: FailedUpload) -> Self {
self.failed_transfers.push(input);
self
}

/// Set a list of failed uploads
pub fn set_failed_transfers(mut self, input: Vec<FailedUploadTransfer>) -> Self {
pub fn set_failed_transfers(mut self, input: Vec<FailedUpload>) -> Self {
self.failed_transfers = input;
self
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::error::ErrorKind;
use crate::io::InputStream;
use crate::operation::upload::UploadInputBuilder;
use crate::operation::DEFAULT_DELIMITER;
use crate::types::{FailedTransferPolicy, FailedUploadTransfer, UploadFilter};
use crate::types::{FailedTransferPolicy, FailedUpload, UploadFilter};
use crate::{error, types::UploadFilterItem};

#[derive(Debug)]
Expand Down Expand Up @@ -223,7 +223,7 @@ fn handle_failed_upload(
FailedTransferPolicy::Continue => {
let mut failures = ctx.state.failed_uploads.lock().unwrap();

let failed_transfer = FailedUploadTransfer {
let failed_transfer = FailedUpload {
input: match object_key {
key @ Some(_) => Some(
UploadInputBuilder::default()
Expand Down
12 changes: 5 additions & 7 deletions aws-s3-transfer-manager/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ fn all_objects_filter(obj: &aws_sdk_s3::types::Object) -> bool {
!is_folder
}

/// Detailed information about a failed object download transfer
/// Detailed information about a failed object download
#[non_exhaustive]
#[derive(Debug)]
pub struct FailedDownloadTransfer {
pub struct FailedDownload {
/// The input for the download object operation that failed
pub(crate) input: crate::operation::download::DownloadInput,

/// The error encountered downloading the object
pub(crate) error: crate::error::Error,
}

impl FailedDownloadTransfer {
impl FailedDownload {
/// The input for the download object operation that failed
pub fn input(&self) -> &crate::operation::download::DownloadInput {
&self.input
Expand Down Expand Up @@ -217,14 +217,12 @@ impl<'a> UploadFilterItem<'a> {
/// Detailed information about a failed upload
#[non_exhaustive]
#[derive(Debug)]
pub struct FailedUploadTransfer {
pub struct FailedUpload {
pub(crate) input: Option<crate::operation::upload::UploadInput>,
pub(crate) error: crate::error::Error,
}

// TODO - Omit "Transfer" from struct name?
// "Transfer" is generic for "upload or download" but this already has "Upload" in the name
impl FailedUploadTransfer {
impl FailedUpload {
/// The input for the failed object upload
pub fn input(&self) -> Option<&crate::operation::upload::UploadInput> {
self.input.as_ref()
Expand Down

0 comments on commit f500116

Please sign in to comment.