Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3s-fs: fix path matching and add start_after #112

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions crates/s3s-fs/src/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,17 @@ impl S3 for FileSystem {
let file_path = entry.path();
let key = try_!(file_path.strip_prefix(&path));
let delimiter = input.delimiter.as_ref().map_or("/", |d| d.as_str());
let Some(key_str) = normalize_path(key, delimiter) else { continue };
let Some(key_str) = normalize_path(key, delimiter) else {
continue;
};

if let Some(ref prefix) = input.prefix {
let prefix_path: PathBuf = prefix.split(delimiter).collect();
if !key.starts_with(prefix_path) {

let key_s = format!("{}", key.display());
let prefix_path_s = format!("{}", prefix_path.display());

if !key_s.starts_with(&prefix_path_s) {
continue;
}
}
Expand All @@ -389,6 +395,15 @@ impl S3 for FileSystem {
lhs_key.cmp(rhs_key)
});

let objects = if let Some(marker) = &input.start_after {
objects
.into_iter()
.skip_while(|n| n.key.as_deref().unwrap_or("") <= marker.as_str())
.collect()
} else {
objects
};

let key_count = try_!(i32::try_from(objects.len()));

let output = ListObjectsV2Output {
Expand Down