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

fix(server): return the correct file on multiple files with same name #234

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions fixtures/test-multiple-files-upload-not-found/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[server]
address = "127.0.0.1:8000"
max_content_length = "10MB"
upload_path = "./upload"

[paste]
default_extension = "txt"
duplicate_files = true
delete_expired_files = { enabled = true, interval = "1h" }
20 changes: 20 additions & 0 deletions fixtures/test-multiple-files-upload-not-found/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

content="test data"

setup() {
echo "$content" > file
}

run_test() {
file_url=$(curl -s -F "file=@file" -H "expire:2s" localhost:8000)
file_url=$(curl -s -F "file=@file" -H "expire:1s" localhost:8000)
sleep 2
file_url=$(curl -s -F "file=@file" -H "expire:1m" localhost:8000)
test "$content" = "$(curl -s $file_url)"
}

teardown() {
rm file
rm -r upload
}
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn glob_match_file(mut path: PathBuf) -> Result<PathBuf, ActixError> {
);
if let Some(glob_path) = glob(&format!("{}.[0-9]*", path.to_string_lossy()))
.map_err(error::ErrorInternalServerError)?
.next()
.last()
{
let glob_path = glob_path.map_err(error::ErrorInternalServerError)?;
if let Some(extension) = glob_path
Expand Down
Loading