diff --git a/src/main.rs b/src/main.rs index bd7783b..e79d7e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,11 @@ async fn main() -> Result<()> { fs::create_dir_all(tempdir)?; } + let archive_dir = Path::new("project-archives"); + if !archive_dir.exists() { + fs::create_dir_all(archive_dir)?; + } + let app = routes::router() .layer(Extension(AuthToken(upload_token))); diff --git a/src/routes.rs b/src/routes.rs index e249e5a..c358c3b 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -15,7 +15,7 @@ pub fn router() -> Router { } async fn get_asset(Path((project, filename)): Path<(String, String)>) -> Result<(HeaderMap, Vec), StatusCode> { - let path = path::Path::new("project_archives") + let path = path::Path::new("project-archives") .join(format!("{project}.zip")); if path.exists() { let data = { @@ -69,7 +69,7 @@ fn find_asset(mut zip: ZipArchive, filename: async fn upload_project(mut multipart: Multipart, _auth: Authed, Path(project): Path) -> Result<(), StatusCode> { while let Some(field) = multipart.next_field().await.map_err(|_| StatusCode::BAD_REQUEST)? { - let path = path::Path::new("project_archives") + let path = path::Path::new("project-archives") .join(format!("{project}.zip")); return if let Err(e) = stream_to_file(path, field).await { tracing::error!(%e, "failed to upload project archive");