improvement to S3 bucket list_files

This commit is contained in:
Alek Westover
2023-06-14 08:48:25 -04:00
parent 30815582a7
commit 4b21d23785
+10 -7
View File
@@ -337,9 +337,7 @@ impl RemoteStorage for S3Bucket {
&self,
folder: Option<&RemotePath>
) -> anyhow::Result<Vec<RemotePath>>{
// THIS IS A somewhat messed up prototype
// THIS IS A PROTOTYPE; WIP
let folder_name = folder.map(|x|
String::from(
x.object_name().expect("something went wrong computing folder name")
@@ -357,11 +355,16 @@ impl RemoteStorage for S3Bucket {
let mut all_files = vec![];
for object in resp.contents().unwrap() {
let x = object.key().unwrap();
let y = RemotePath::new(Path::new(x)).unwrap();
all_files.push(y);
let mut object_path = Path::new(object.key().unwrap());
if let Some(prefix_in_bucket) = &self.prefix_in_bucket {
object_path = object_path.strip_prefix(prefix_in_bucket)?;
if object_path == Path::new("") {
continue;
}
}
let remote_path = RemotePath::new(object_path)?;
all_files.push(remote_path);
}
Ok(all_files)
}