Fix listing of S3 prefixes not terminated by a slash #3
|
@ -78,7 +78,6 @@ enum FileView {
|
|||
|
||||
#[derive(Serialize)]
|
||||
struct FileViewItem {
|
||||
parent: String,
|
||||
path: String,
|
||||
size: String,
|
||||
size_bytes: u64,
|
||||
|
@ -176,7 +175,6 @@ async fn s3_fileview(path: &PathBuf) -> Result<Vec<FileViewItem>, Error> {
|
|||
let folders = list.common_prefixes.iter().flatten().map(|dir| {
|
||||
let path = dir.prefix.strip_prefix(&prefix);
|
||||
path.map(|path| FileViewItem {
|
||||
parent:s3_folder_path.clone(),
|
||||
path: path.to_owned(),
|
||||
size_bytes: 0,
|
||||
size: "[DIR]".to_owned(),
|
||||
|
@ -187,7 +185,6 @@ async fn s3_fileview(path: &PathBuf) -> Result<Vec<FileViewItem>, Error> {
|
|||
let files = list.contents.iter().map(|obj| {
|
||||
let path = obj.key.strip_prefix(&prefix);
|
||||
path.map(|path| FileViewItem {
|
||||
parent:s3_folder_path.clone(),
|
||||
path: path.to_owned(),
|
||||
size_bytes: obj.size,
|
||||
size: size_bytes_to_human(obj.size),
|
||||
|
@ -246,9 +243,8 @@ fn rocket() -> _ {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use rstest::rstest;
|
||||
// Note this useful idiom: importing names from outer (for mod tests) scope.
|
||||
use super::*;
|
||||
use rstest::rstest;
|
||||
|
||||
#[rstest]
|
||||
#[case(1024, "1.024 kB")]
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
if (window.location.pathname.endsWith('/') === false) {
|
||||
window.location.href = window.location + "/";
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: monospace;
|
||||
|
@ -44,7 +49,7 @@
|
|||
|
||||
{% for object in objects %}
|
||||
<tr>
|
||||
<td><a href="/{{ object.parent | urlencode }}{{ object.path | urlencode }}" data-size-bytes="{{ object.size_bytes }}">{{ object.path }}</a></td>
|
||||
<td><a href="{{ object.path | urlencode }}" data-size-bytes="{{ object.size_bytes }}">{{ object.path }}</a></td>
|
||||
<td>{{ object.size }}</td>
|
||||
<td>{{ object.last_modification}}</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue