|
|
@ -1,9 +1,11 @@ |
|
|
|
use std::env; |
|
|
|
use std::env; |
|
|
|
|
|
|
|
use std::collections::HashSet; |
|
|
|
|
|
|
|
use std::path::Path; |
|
|
|
|
|
|
|
|
|
|
|
use rusoto_core::Region; |
|
|
|
use rusoto_core::Region; |
|
|
|
use rusoto_credential::StaticProvider; |
|
|
|
use rusoto_credential::StaticProvider; |
|
|
|
use rusoto_core::request::HttpClient; |
|
|
|
use rusoto_core::request::HttpClient; |
|
|
|
use rusoto_s3::ListObjectsV2Request; |
|
|
|
use rusoto_s3::ListObjectsRequest; |
|
|
|
use rusoto_s3::S3; |
|
|
|
use rusoto_s3::S3; |
|
|
|
use rusoto_s3::S3Client; |
|
|
|
use rusoto_s3::S3Client; |
|
|
|
|
|
|
|
|
|
|
@ -29,16 +31,40 @@ fn main() { |
|
|
|
region |
|
|
|
region |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
let list_objects_request = ListObjectsV2Request { |
|
|
|
let mut truncated = Some(true); |
|
|
|
|
|
|
|
let mut start_at = None; |
|
|
|
|
|
|
|
let mut files_dirs: HashSet<String> = HashSet::new(); |
|
|
|
|
|
|
|
let mut directory_files: HashSet<String> = HashSet::new(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while truncated.unwrap_or(false) { |
|
|
|
|
|
|
|
let list_objects_request = ListObjectsRequest { |
|
|
|
bucket: bucket.to_owned(), |
|
|
|
bucket: bucket.to_owned(), |
|
|
|
|
|
|
|
marker: start_at, |
|
|
|
..Default::default() |
|
|
|
..Default::default() |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
println!("Request: {:?}", list_objects_request); |
|
|
|
|
|
|
|
|
|
|
|
let _result = client |
|
|
|
let result = client |
|
|
|
.list_objects_v2(list_objects_request) |
|
|
|
.list_objects(list_objects_request) |
|
|
|
.sync() |
|
|
|
.sync() |
|
|
|
.expect("Can't list contents of buckets") |
|
|
|
.expect("Can't list contents of buckets"); |
|
|
|
.contents.unwrap() |
|
|
|
truncated = result.is_truncated; |
|
|
|
|
|
|
|
start_at = result.next_marker; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.contents |
|
|
|
|
|
|
|
.expect("Didn't get any objects") |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
.for_each(|item| { println!("{}", item.key.as_ref().unwrap()) }); |
|
|
|
.for_each(|item| {
|
|
|
|
|
|
|
|
let filename = item.key.as_ref().unwrap(); |
|
|
|
|
|
|
|
if filename.ends_with("/") { |
|
|
|
|
|
|
|
files_dirs.insert(filename.clone()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
directory_files.insert(Path::new(filename).parent().unwrap().to_str().unwrap().to_string() + "/"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
println!("Directories with files:\n{:#?}", directory_files); |
|
|
|
|
|
|
|
println!("Directories with controllers:\n{:#?}", files_dirs); |
|
|
|
|
|
|
|
println!("Difference:\n{:#?}", directory_files.difference(&files_dirs)); |
|
|
|
} |
|
|
|
} |
|
|
|