support index on path missing a trailing slash #612
No reviewers
Labels
No Label
AdminAPI
Bug
Check AWS
CI
Correctness
Critical
Documentation
Ideas
Improvement
Low priority
Newcomer
Performance
S3 Compatibility
Testing
Usability
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Deuxfleurs/garage#612
Loading…
Reference in 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('/')