support index on path missing a trailing slash #612
No reviewers
Labels
No labels
action
check-aws
action
discussion-needed
action
for-external-contributors
action
for-newcomers
action
more-info-needed
action
need-funding
action
triage-required
kind
correctness
kind
ideas
kind
improvement
kind
performance
kind
testing
kind
usability
kind
wrong-behavior
prio
critical
prio
low
scope
admin-api
scope
background-healing
scope
build
scope
documentation
scope
k8s
scope
layout
scope
metadata
scope
ops
scope
rpc
scope
s3-api
scope
security
scope
telemetry
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Deuxfleurs/garage#612
Loading…
Reference in a new issue
No description provided.
Delete branch "compat/index-without-trailing-slash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #557
New behavior
Existing behaviors
Content of the bucket
Example with a 404
fbd40bac0d
to63da1d2443
One logic error (check_key_exists should return a
Result<bool>
) and small stylistic improvement suggestion.@ -171,0 +174,4 @@
.object_table
.get(&bucket_id, &key.to_string())
.await
.ok()
You should not use
.ok()
here but?
, because ifobject_table.get
returns an error we cannot consider that the result of this function is correct.Overall, please rewrite the function as:
@ -332,3 +365,1 @@
Cow::Borrowed(pu8) => Ok((&pu8[1..]).into()),
Cow::Owned(pu8) => Ok(pu8[1..].to_string().into()),
},
let base_key = &path_utf8[1..];
361-365 can be rewritten more elegantly as:
This avoids slicing which is "unelegant" as it is not guaranteed to be correct (here we know that it works but with additionnal reasoning).
@ -334,1 +365,3 @@
},
let base_key = &path_utf8[1..];
let is_bucket_root = base_key.len() == 0;
let is_trailing_slash = path_utf8.chars().last().map(|v| v == '/').unwrap_or(false);
can be written shorter as
path_utf8.ends_with('/')