diff --git a/server/main.py b/server/main.py index 1cbf52a..2f10373 100644 --- a/server/main.py +++ b/server/main.py @@ -62,6 +62,7 @@ def walk_archive_paths(base_path: str, file_paths: List[str]) -> List[Archive]: size = 0 for file in file_paths: full_path = base / file.strip("/") + print(full_path) if full_path.is_file(): zip_paths.append({"fs": str(full_path), "n": full_path.name}) @@ -78,6 +79,12 @@ def walk_archive_paths(base_path: str, file_paths: List[str]) -> List[Archive]: ) size += file_path.stat().st_size raise_for_size(size) + else: + # No file/folder exists at the requested path, so raise a 404. + raise HTTPException( + status_code=404, + detail="One or more of the requested files could not be found.", + ) return zip_paths diff --git a/server/tests/test_utils.py b/server/tests/test_utils.py index fd4b412..f95bc78 100644 --- a/server/tests/test_utils.py +++ b/server/tests/test_utils.py @@ -64,6 +64,12 @@ def test_walk_archive(tmp_path): ] +def test_walk_archive_404(tmp_path): + base = tmp_path + with pytest.raises(HTTPException): + walk_archive_paths(base, ["nonexistent_file.txt"]) + + @pytest.fixture def mock_get_success(monkeypatch, request): import requests