diff --git a/Cargo.lock b/Cargo.lock index 752ed5c..f3fd7ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3148,7 +3148,7 @@ dependencies = [ [[package]] name = "redacter" -version = "0.9.0" +version = "0.10.0" dependencies = [ "anyhow", "arboard", diff --git a/Cargo.toml b/Cargo.toml index f081dfd..d115dd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "redacter" -version = "0.9.0" +version = "0.10.0" edition = "2021" authors = ["Abdulla Abdurakhmanov "] license = "Apache-2.0" diff --git a/src/args.rs b/src/args.rs index beb5900..27ee72d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -28,8 +28,17 @@ pub enum CliCommand { help = "Destination directory or file such as /tmp, /tmp/file.txt or gs://bucket/file.txt and others supported providers" )] destination: String, + #[arg(short = 'm', long, help = "Maximum size of files to copy in bytes")] - max_size_limit: Option, + max_size_limit: Option, + + #[arg( + short = 'n', + long, + help = "Maximum number of files to copy. Sort order is not guaranteed and depends on the provider" + )] + max_files_limit: Option, + #[arg( short = 'f', long, @@ -50,7 +59,7 @@ pub enum CliCommand { )] source: String, #[arg(short = 'm', long, help = "Maximum size of files to copy in bytes")] - max_size_limit: Option, + max_size_limit: Option, #[arg( short = 'f', long, diff --git a/src/commands/copy_command.rs b/src/commands/copy_command.rs index 02d12c5..abe8418 100644 --- a/src/commands/copy_command.rs +++ b/src/commands/copy_command.rs @@ -21,12 +21,14 @@ pub struct CopyCommandResult { pub struct CopyCommandOptions { pub file_matcher: FileMatcher, pub file_mime_override: FileMimeOverride, + pub max_files_limit: Option, } impl CopyCommandOptions { pub fn new( filename_filter: Option, - max_size_limit: Option, + max_size_limit: Option, + max_files_limit: Option, mime_override: Vec<(mime::Mime, globset::Glob)>, ) -> Self { let filename_matcher = filename_filter @@ -35,6 +37,7 @@ impl CopyCommandOptions { CopyCommandOptions { file_matcher: FileMatcher::new(filename_matcher, max_size_limit), file_mime_override: FileMimeOverride::new(mime_override), + max_files_limit, } } } @@ -90,10 +93,12 @@ pub async fn command_copy( }); } bar.println("Copying directory and listing source files..."); - let source_files_result = source_fs.list_files(Some(&options.file_matcher)).await?; + let source_files_result = source_fs + .list_files(Some(&options.file_matcher), options.max_files_limit) + .await?; let source_files: Vec = source_files_result.files; let files_found = source_files.len(); - let files_total_size: u64 = source_files + let files_total_size: usize = source_files .iter() .map(|file| file.file_size.unwrap_or(0)) .sum(); @@ -102,7 +107,7 @@ pub async fn command_copy( format!( "Found {} files. Total size: {}", bold_style.apply_to(files_found), - bold_style.apply_to(HumanBytes(files_total_size)) + bold_style.apply_to(HumanBytes(files_total_size as u64)) ) .as_str(), ); @@ -292,7 +297,7 @@ async fn transfer_and_redact_file< None ), bold_style.apply_to(pad_str( - HumanBytes(file_ref.file_size.unwrap_or(0)) + HumanBytes(file_ref.file_size.map(|sz| sz as u64).unwrap_or(0_u64)) .to_string() .as_str(), 16, diff --git a/src/commands/ls_command.rs b/src/commands/ls_command.rs index 1a17997..51e9526 100644 --- a/src/commands/ls_command.rs +++ b/src/commands/ls_command.rs @@ -12,7 +12,7 @@ pub struct LsCommandOptions { } impl LsCommandOptions { - pub fn new(filename_filter: Option, max_size_limit: Option) -> Self { + pub fn new(filename_filter: Option, max_size_limit: Option) -> Self { let filename_matcher = filename_filter .as_ref() .map(|filter| filter.compile_matcher()); @@ -29,8 +29,10 @@ pub async fn command_ls(term: &Term, source: &str, options: LsCommandOptions) -> term.write_line(format!("Listing files in {}.", bold_style.apply_to(source)).as_str())?; let app_reporter = crate::reporter::AppReporter::from(term); let mut source_fs = DetectFileSystem::open(source, &app_reporter).await?; - let list_files_result = source_fs.list_files(Some(&options.file_matcher)).await?; - let total_size: u64 = list_files_result + let list_files_result = source_fs + .list_files(Some(&options.file_matcher), None) + .await?; + let total_size: usize = list_files_result .files .iter() .map(|f| f.file_size.unwrap_or(0)) @@ -83,7 +85,11 @@ pub async fn command_ls(term: &Term, source: &str, options: LsCommandOptions) -> None ), highlighted.apply_to(pad_str( - format!("{}", HumanBytes(file.file_size.unwrap_or(0))).as_str(), + format!( + "{}", + HumanBytes(file.file_size.map(|sz| sz as u64).unwrap_or(0)) + ) + .as_str(), 16, Alignment::Left, None @@ -98,7 +104,7 @@ pub async fn command_ls(term: &Term, source: &str, options: LsCommandOptions) -> format!( "{} files found. Total size: {}", highlighted.apply_to(list_files_result.files.len()), - highlighted.apply_to(HumanBytes(total_size)) + highlighted.apply_to(HumanBytes(total_size as u64)) ) .as_str(), )?; diff --git a/src/file_systems/aws_s3.rs b/src/file_systems/aws_s3.rs index 30f5826..d086418 100644 --- a/src/file_systems/aws_s3.rs +++ b/src/file_systems/aws_s3.rs @@ -54,7 +54,12 @@ impl<'a> AwsS3FileSystem<'a> { prefix: Option, continuation_token: Option, file_matcher: &Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult { + if max_files_limit.iter().any(|v| *v == 0) { + return Ok(ListFilesResult::EMPTY); + } + let list_req = self .client .list_objects_v2() @@ -76,12 +81,27 @@ impl<'a> AwsS3FileSystem<'a> { FileSystemRef { relative_path, media_type, - file_size: item.size.map(|v| v as u64), + file_size: item.size.map(|v| v as usize), } }) }) + .take(max_files_limit.unwrap_or(usize::MAX)) .collect(); + let all_found_len = all_found.len(); + let filtered_files: Vec = all_found + .into_iter() + .filter(|file_ref| { + file_matcher.iter().all(|matcher| { + matches!(matcher.matches(file_ref), FileMatcherResult::Matched) + }) + }) + .collect(); + let skipped = all_found_len - filtered_files.len(); + + let new_max_files_limit = + max_files_limit.map(|v| v.saturating_sub(filtered_files.len())); + let next_list_result = if list_resp .next_continuation_token .as_ref() @@ -92,23 +112,13 @@ impl<'a> AwsS3FileSystem<'a> { None, list_resp.next_continuation_token, file_matcher, + new_max_files_limit, ) .await? } else { ListFilesResult::EMPTY }; - let all_found_len = all_found.len(); - let filtered_files: Vec = all_found - .into_iter() - .filter(|file_ref| { - file_matcher.iter().all(|matcher| { - matches!(matcher.matches(file_ref), FileMatcherResult::Matched) - }) - }) - .collect(); - let skipped = all_found_len - filtered_files.len(); - Ok(ListFilesResult { files: [filtered_files, next_list_result.files].concat(), skipped: next_list_result.skipped + skipped, @@ -157,7 +167,7 @@ impl<'a> FileSystemConnection<'a> for AwsS3FileSystem<'a> { .map(|v| v.parse()) .transpose()? .or_else(|| mime_guess::from_path(relative_path.value()).first()), - file_size: object.content_length.map(|v| v as u64), + file_size: object.content_length.map(|v| v as usize), }; let reader = object.body.into_async_read(); @@ -194,6 +204,7 @@ impl<'a> FileSystemConnection<'a> for AwsS3FileSystem<'a> { async fn list_files( &mut self, file_matcher: Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult { self.reporter.report(format!( "Listing files in bucket: {} with prefix: {}", @@ -208,6 +219,7 @@ impl<'a> FileSystemConnection<'a> for AwsS3FileSystem<'a> { }, None, &file_matcher, + max_files_limit, ) .await } else { @@ -277,7 +289,7 @@ mod tests { Some(&FileSystemRef { relative_path: "test-upload.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_data.len() as u64), + file_size: Some(test_data.len()), }), ) .await?; @@ -286,7 +298,7 @@ mod tests { .download(Some(&FileSystemRef { relative_path: "test-upload.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_data.len() as u64), + file_size: Some(test_data.len()), })) .await?; @@ -297,7 +309,7 @@ mod tests { assert_eq!(file_ref.relative_path.value(), "test-upload.txt"); assert_eq!(file_ref.media_type, Some(mime::TEXT_PLAIN)); - assert_eq!(file_ref.file_size, Some(test_data.len() as u64)); + assert_eq!(file_ref.file_size, Some(test_data.len())); fs.close().await?; @@ -325,17 +337,17 @@ mod tests { Some(&FileSystemRef { relative_path: "test-upload.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_data.len() as u64), + file_size: Some(test_data.len()), }), ) .await?; - let list_result = fs.list_files(None).await?; + let list_result = fs.list_files(None, None).await?; assert_eq!(list_result.files.len(), 1); let file_ref = &list_result.files[0]; assert_eq!(file_ref.relative_path.value(), "test-upload.txt"); assert_eq!(file_ref.media_type, Some(mime::TEXT_PLAIN)); - assert_eq!(file_ref.file_size, Some(test_data.len() as u64)); + assert_eq!(file_ref.file_size, Some(test_data.len())); fs.close().await?; diff --git a/src/file_systems/clipboard.rs b/src/file_systems/clipboard.rs index 6d8b1c0..08af745 100644 --- a/src/file_systems/clipboard.rs +++ b/src/file_systems/clipboard.rs @@ -58,7 +58,7 @@ impl<'a> FileSystemConnection<'a> for ClipboardFileSystem<'a> { FileSystemRef { relative_path: format!("{}.png", filename).into(), media_type: Some(mime::IMAGE_PNG), - file_size: Some(png_image_bytes.len() as u64), + file_size: Some(png_image_bytes.len()), }, Box::new(futures::stream::iter(vec![Ok(bytes::Bytes::from( png_image_bytes, @@ -77,7 +77,7 @@ impl<'a> FileSystemConnection<'a> for ClipboardFileSystem<'a> { FileSystemRef { relative_path: format!("{}.txt", filename).into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(text.len() as u64), + file_size: Some(text.len()), }, Box::new(futures::stream::iter(vec![Ok(bytes::Bytes::from(text))])), )) @@ -137,6 +137,7 @@ impl<'a> FileSystemConnection<'a> for ClipboardFileSystem<'a> { async fn list_files( &mut self, _file_matcher: Option<&FileMatcher>, + _max_files_limit: Option, ) -> AppResult { self.reporter .report("Listing in clipboard is not supported")?; @@ -201,7 +202,7 @@ mod tests { let downloaded_content = std::str::from_utf8(&flattened_bytes)?; assert_eq!(downloaded_content, test_content); assert_eq!(file_ref.media_type, Some(mime::TEXT_PLAIN)); - assert_eq!(file_ref.file_size, Some(test_content.len() as u64)); + assert_eq!(file_ref.file_size, Some(test_content.len())); fs.close().await?; @@ -220,7 +221,7 @@ mod tests { let mut writer = std::io::Cursor::new(Vec::new()); test_content.write_to(&mut writer, ImageFormat::Png)?; let png_image_bytes = writer.into_inner(); - let png_images_bytes_len = png_image_bytes.len() as u64; + let png_images_bytes_len = png_image_bytes.len(); fs.upload( futures::stream::iter(vec![Ok(bytes::Bytes::from(png_image_bytes))]), diff --git a/src/file_systems/gcs.rs b/src/file_systems/gcs.rs index 5234472..6006514 100644 --- a/src/file_systems/gcs.rs +++ b/src/file_systems/gcs.rs @@ -49,7 +49,12 @@ impl<'a> GoogleCloudStorageFileSystem<'a> { prefix: Option, page_token: Option, file_matcher: &Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult { + if max_files_limit.iter().any(|v| *v == 0) { + return Ok(ListFilesResult::EMPTY); + } + let config = self .google_rest_client .create_google_storage_v1_config() @@ -75,17 +80,11 @@ impl<'a> GoogleCloudStorageFileSystem<'a> { item.name.map(|name| FileSystemRef { relative_path: name.trim_start_matches(&self.object_name).into(), media_type: item.content_type.and_then(|v| v.parse().ok()), - file_size: item.size.and_then(|v| v.parse::().ok()), + file_size: item.size.and_then(|v| v.parse::().ok()), }) }) .collect(); - let next_list_result = - if list.next_page_token.as_ref().iter().any(|v| !v.is_empty()) { - self.list_files_with_token(None, list.next_page_token, file_matcher) - .await? - } else { - ListFilesResult::EMPTY - }; + let all_found_len = all_found.len(); let filtered_files: Vec = all_found .into_iter() @@ -94,8 +93,26 @@ impl<'a> GoogleCloudStorageFileSystem<'a> { matches!(matcher.matches(file_ref), FileMatcherResult::Matched) }) }) + .take(max_files_limit.unwrap_or(usize::MAX)) .collect(); let skipped = all_found_len - filtered_files.len(); + + let new_max_files_limit = + max_files_limit.map(|v| v.saturating_sub(filtered_files.len())); + + let next_list_result = + if list.next_page_token.as_ref().iter().any(|v| !v.is_empty()) { + self.list_files_with_token( + None, + list.next_page_token, + file_matcher, + new_max_files_limit, + ) + .await? + } else { + ListFilesResult::EMPTY + }; + ListFilesResult { files: [filtered_files, next_list_result.files].concat(), skipped: next_list_result.skipped + skipped, @@ -151,7 +168,7 @@ impl<'a> FileSystemConnection<'a> for GoogleCloudStorageFileSystem<'a> { .map(|v| v.parse()) .transpose()? .or_else(|| mime_guess::from_path(relative_path.value()).first()), - file_size: object.size.and_then(|v| v.parse::().ok()), + file_size: object.size.and_then(|v| v.parse::().ok()), }; let stream = gcloud_sdk::google_rest_apis::storage_v1::objects_api::storage_objects_get_stream( @@ -200,6 +217,7 @@ impl<'a> FileSystemConnection<'a> for GoogleCloudStorageFileSystem<'a> { async fn list_files( &mut self, file_matcher: Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult { self.reporter.report(format!( "Listing files in bucket: {} with prefix: {}", @@ -211,7 +229,7 @@ impl<'a> FileSystemConnection<'a> for GoogleCloudStorageFileSystem<'a> { } else { None }; - self.list_files_with_token(prefix, None, &file_matcher) + self.list_files_with_token(prefix, None, &file_matcher, max_files_limit) .await } else { Ok(ListFilesResult::EMPTY) @@ -278,7 +296,7 @@ mod tests { Some(&FileSystemRef { relative_path: "test-upload.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_data.len() as u64), + file_size: Some(test_data.len()), }), ) .await?; @@ -287,7 +305,7 @@ mod tests { .download(Some(&FileSystemRef { relative_path: "test-upload.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_data.len() as u64), + file_size: Some(test_data.len()), })) .await?; @@ -298,7 +316,7 @@ mod tests { assert_eq!(file_ref.relative_path.value(), "test-upload.txt"); assert_eq!(file_ref.media_type, Some(mime::TEXT_PLAIN)); - assert_eq!(file_ref.file_size, Some(test_data.len() as u64)); + assert_eq!(file_ref.file_size, Some(test_data.len())); fs.close().await?; @@ -326,17 +344,17 @@ mod tests { Some(&FileSystemRef { relative_path: "test-upload.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_data.len() as u64), + file_size: Some(test_data.len()), }), ) .await?; - let list_result = fs.list_files(None).await?; + let list_result = fs.list_files(None, None).await?; assert_eq!(list_result.files.len(), 1); let file_ref = &list_result.files[0]; assert_eq!(file_ref.relative_path.value(), "test-upload.txt"); assert_eq!(file_ref.media_type, Some(mime::TEXT_PLAIN)); - assert_eq!(file_ref.file_size, Some(test_data.len() as u64)); + assert_eq!(file_ref.file_size, Some(test_data.len())); fs.close().await?; diff --git a/src/file_systems/local.rs b/src/file_systems/local.rs index a8bca8b..2999e5a 100644 --- a/src/file_systems/local.rs +++ b/src/file_systems/local.rs @@ -37,7 +37,12 @@ impl<'a> LocalFileSystem<'a> { &self, dir_path: String, file_matcher: &Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult { + if max_files_limit.iter().any(|v| *v == 0) { + return Ok(ListFilesResult::EMPTY); + } + let mut entries = tokio::fs::read_dir(dir_path).await?; let mut files = Vec::new(); let mut skipped: usize = 0; @@ -52,7 +57,7 @@ impl<'a> LocalFileSystem<'a> { .replace(self.root_path.as_str(), "") .into(), media_type: mime_guess::from_path(entry.path()).first(), - file_size: Some(entry.metadata().await?.len()), + file_size: Some(entry.metadata().await?.len() as usize), }; if file_matcher .iter() @@ -63,12 +68,23 @@ impl<'a> LocalFileSystem<'a> { skipped += 1; } } else if file_type.is_dir() { + let new_max_files_limit = max_files_limit.map(|v| v.saturating_sub(files.len())); let dir_files = self - .list_files_recursive(entry.path().to_string_lossy().to_string(), file_matcher) + .list_files_recursive( + entry.path().to_string_lossy().to_string(), + file_matcher, + new_max_files_limit, + ) .await?; skipped += dir_files.skipped; files.extend(dir_files.files); } + + if let Some(limit) = max_files_limit { + if files.len() >= limit { + break; + } + } } Ok(ListFilesResult { files, skipped }) } @@ -98,7 +114,7 @@ impl<'a> FileSystemConnection<'a> for LocalFileSystem<'a> { let file_ref = FileSystemRef { relative_path: relative_file_path.into(), media_type: mime_guess::from_path(&file_path).first(), - file_size: Some(file_metadata.len()), + file_size: Some(file_metadata.len() as usize), }; Ok((file_ref, Box::new(stream))) } @@ -127,12 +143,13 @@ impl<'a> FileSystemConnection<'a> for LocalFileSystem<'a> { async fn list_files( &mut self, file_matcher: Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult { self.reporter .report(format!("Listing files in dir: {}", self.root_path.as_str()))?; let source = PathBuf::from(self.root_path.as_str()); let source_str = source.to_string_lossy().to_string(); - self.list_files_recursive(source_str.clone(), &file_matcher) + self.list_files_recursive(source_str.clone(), &file_matcher, max_files_limit) .await } @@ -203,7 +220,7 @@ mod tests { assert_eq!(downloaded_content, temp_content); assert_eq!(file_ref.relative_path.value(), "temp_file.txt"); assert_eq!(file_ref.media_type, Some(mime::TEXT_PLAIN)); - assert_eq!(file_ref.file_size, Some(temp_content.len() as u64)); + assert_eq!(file_ref.file_size, Some(temp_content.len())); fs.close().await?; @@ -271,7 +288,7 @@ mod tests { ) .await?; - let list_files_result = fs.list_files(None).await?; + let list_files_result = fs.list_files(None, None).await?; assert_eq!(list_files_result.files.len(), 1); assert_eq!( list_files_result.files[0].relative_path.value(), diff --git a/src/file_systems/mod.rs b/src/file_systems/mod.rs index 2c905f5..7644d02 100644 --- a/src/file_systems/mod.rs +++ b/src/file_systems/mod.rs @@ -45,7 +45,7 @@ pub struct AbsoluteFilePath { pub struct FileSystemRef { pub relative_path: RelativeFilePath, pub media_type: Option, - pub file_size: Option, + pub file_size: Option, } #[derive(Debug, Clone)] @@ -79,6 +79,7 @@ pub trait FileSystemConnection<'a> { async fn list_files( &mut self, file_matcher: Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult; async fn close(self) -> AppResult<()>; @@ -177,14 +178,17 @@ impl<'a> FileSystemConnection<'a> for DetectFileSystem<'a> { async fn list_files( &mut self, file_matcher: Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult { match self { - DetectFileSystem::Local(fs) => fs.list_files(file_matcher).await, - DetectFileSystem::GoogleCloudStorage(fs) => fs.list_files(file_matcher).await, - DetectFileSystem::AwsS3(fs) => fs.list_files(file_matcher).await, - DetectFileSystem::ZipFile(fs) => fs.list_files(file_matcher).await, + DetectFileSystem::Local(fs) => fs.list_files(file_matcher, max_files_limit).await, + DetectFileSystem::GoogleCloudStorage(fs) => { + fs.list_files(file_matcher, max_files_limit).await + } + DetectFileSystem::AwsS3(fs) => fs.list_files(file_matcher, max_files_limit).await, + DetectFileSystem::ZipFile(fs) => fs.list_files(file_matcher, max_files_limit).await, #[cfg(feature = "clipboard")] - DetectFileSystem::Clipboard(fs) => fs.list_files(file_matcher).await, + DetectFileSystem::Clipboard(fs) => fs.list_files(file_matcher, max_files_limit).await, } } diff --git a/src/file_systems/noop.rs b/src/file_systems/noop.rs index 4cd64b6..73f5ba2 100644 --- a/src/file_systems/noop.rs +++ b/src/file_systems/noop.rs @@ -44,6 +44,7 @@ impl<'a> FileSystemConnection<'a> for NoopFileSystem<'a> { async fn list_files( &mut self, _file_matcher: Option<&FileMatcher>, + _max_files_limit: Option, ) -> AppResult { self.reporter .report("NoopFileSystem does not support list_files")?; diff --git a/src/file_systems/zip.rs b/src/file_systems/zip.rs index f56e67d..4b1b593 100644 --- a/src/file_systems/zip.rs +++ b/src/file_systems/zip.rs @@ -133,13 +133,18 @@ impl<'a> FileSystemConnection<'a> for ZipFileSystem<'a> { async fn list_files( &mut self, file_matcher: Option<&FileMatcher>, + max_files_limit: Option, ) -> AppResult { self.extract_zip_for_read().await?; match self.mode { Some(ZipFileSystemMode::Read { _temp_dir: _, ref mut temp_file_system, - }) => temp_file_system.list_files(file_matcher).await, + }) => { + temp_file_system + .list_files(file_matcher, max_files_limit) + .await + } _ => Err(AppError::SystemError { message: "ZipFileSystem is not in read mode".into(), }), @@ -213,7 +218,7 @@ mod tests { assert_eq!(downloaded_content, std::str::from_utf8(test_content)?); assert_eq!(file_ref.relative_path.value(), "file1.txt"); assert_eq!(file_ref.media_type, Some(mime::TEXT_PLAIN)); - assert_eq!(file_ref.file_size, Some(test_content.len() as u64)); + assert_eq!(file_ref.file_size, Some(test_content.len())); fs.close().await?; @@ -274,7 +279,7 @@ mod tests { &reporter, ) .await?; - let list_files_result = fs.list_files(None).await?; + let list_files_result = fs.list_files(None, None).await?; assert_eq!(list_files_result.files.len(), 2); assert_eq!(list_files_result.skipped, 0); diff --git a/src/file_tools/file_matcher.rs b/src/file_tools/file_matcher.rs index ca45b16..311c264 100644 --- a/src/file_tools/file_matcher.rs +++ b/src/file_tools/file_matcher.rs @@ -4,7 +4,7 @@ use rvstruct::ValueStruct; #[derive(Debug, Clone)] pub struct FileMatcher { pub filename_matcher: Option, - pub max_size_limit: Option, + pub max_size_limit: Option, } #[derive(Debug, Clone, PartialEq)] @@ -17,7 +17,7 @@ pub enum FileMatcherResult { impl FileMatcher { pub fn new( filename_matcher: Option, - max_size_limit: Option, + max_size_limit: Option, ) -> Self { FileMatcher { filename_matcher, diff --git a/src/main.rs b/src/main.rs index 71abcc6..b4f44e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,11 +67,17 @@ async fn handle_args(cli: CliArgs, term: &Term) -> AppResult<()> { source, destination, max_size_limit, + max_files_limit, filename_filter, redacter_args, mime_override, } => { - let options = CopyCommandOptions::new(filename_filter, max_size_limit, mime_override); + let options = CopyCommandOptions::new( + filename_filter, + max_size_limit, + max_files_limit, + mime_override, + ); let copy_result = command_copy( term, &source, diff --git a/src/redacters/aws_comprehend.rs b/src/redacters/aws_comprehend.rs index ec8fd53..d5c231d 100644 --- a/src/redacters/aws_comprehend.rs +++ b/src/redacters/aws_comprehend.rs @@ -117,7 +117,7 @@ mod tests { let file_ref = FileSystemRef { relative_path: "temp_file.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_content.len() as u64), + file_size: Some(test_content.len()), }; let content = RedacterDataItemContent::Value(test_content.to_string()); diff --git a/src/redacters/gcp_dlp.rs b/src/redacters/gcp_dlp.rs index 0cdd63e..9b27971 100644 --- a/src/redacters/gcp_dlp.rs +++ b/src/redacters/gcp_dlp.rs @@ -445,7 +445,7 @@ mod tests { let file_ref = FileSystemRef { relative_path: "temp_file.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_content.len() as u64), + file_size: Some(test_content.len()), }; let content = RedacterDataItemContent::Value(test_content.to_string()); diff --git a/src/redacters/gemini_llm.rs b/src/redacters/gemini_llm.rs index cb55949..85c9aab 100644 --- a/src/redacters/gemini_llm.rs +++ b/src/redacters/gemini_llm.rs @@ -378,7 +378,7 @@ mod tests { let file_ref = FileSystemRef { relative_path: "temp_file.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_content.len() as u64), + file_size: Some(test_content.len()), }; let content = RedacterDataItemContent::Value(test_content.to_string()); diff --git a/src/redacters/ms_presidio.rs b/src/redacters/ms_presidio.rs index b8ceb5f..d5fbc9c 100644 --- a/src/redacters/ms_presidio.rs +++ b/src/redacters/ms_presidio.rs @@ -229,7 +229,7 @@ mod tests { let file_ref = FileSystemRef { relative_path: "temp_file.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_content.len() as u64), + file_size: Some(test_content.len()), }; let content = RedacterDataItemContent::Value(test_content.to_string()); diff --git a/src/redacters/open_ai_llm.rs b/src/redacters/open_ai_llm.rs index ec94053..68d55a8 100644 --- a/src/redacters/open_ai_llm.rs +++ b/src/redacters/open_ai_llm.rs @@ -359,7 +359,7 @@ mod tests { let file_ref = FileSystemRef { relative_path: "temp_file.txt".into(), media_type: Some(mime::TEXT_PLAIN), - file_size: Some(test_content.len() as u64), + file_size: Some(test_content.len()), }; let content = RedacterDataItemContent::Value(test_content.to_string());