From 5056916a9b44b56eb8cabbe8cab1a95f742f7079 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Tue, 30 Jan 2024 18:04:30 -0500 Subject: [PATCH 1/2] fix(server): file not found, even though on server and not expired --- fixtures/test-fix-218/config.toml | 9 +++++++++ fixtures/test-fix-218/test.sh | 20 ++++++++++++++++++++ src/util.rs | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 fixtures/test-fix-218/config.toml create mode 100755 fixtures/test-fix-218/test.sh diff --git a/fixtures/test-fix-218/config.toml b/fixtures/test-fix-218/config.toml new file mode 100644 index 00000000..a94fcc30 --- /dev/null +++ b/fixtures/test-fix-218/config.toml @@ -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" } diff --git a/fixtures/test-fix-218/test.sh b/fixtures/test-fix-218/test.sh new file mode 100755 index 00000000..3441e309 --- /dev/null +++ b/fixtures/test-fix-218/test.sh @@ -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 +} diff --git a/src/util.rs b/src/util.rs index d404cfc7..ebc3c9de 100644 --- a/src/util.rs +++ b/src/util.rs @@ -37,7 +37,7 @@ pub fn glob_match_file(mut path: PathBuf) -> Result { ); 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 From b013e8faf1dbdb221c02d0fc0503dda1fbffee69 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Wed, 31 Jan 2024 15:38:32 -0500 Subject: [PATCH 2/2] test: rename test --- .../config.toml | 0 .../test.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename fixtures/{test-fix-218 => test-multiple-files-upload-not-found}/config.toml (100%) rename fixtures/{test-fix-218 => test-multiple-files-upload-not-found}/test.sh (100%) diff --git a/fixtures/test-fix-218/config.toml b/fixtures/test-multiple-files-upload-not-found/config.toml similarity index 100% rename from fixtures/test-fix-218/config.toml rename to fixtures/test-multiple-files-upload-not-found/config.toml diff --git a/fixtures/test-fix-218/test.sh b/fixtures/test-multiple-files-upload-not-found/test.sh similarity index 100% rename from fixtures/test-fix-218/test.sh rename to fixtures/test-multiple-files-upload-not-found/test.sh