fix: Create archives dir if it does not exist
This commit is contained in:
parent
9d2f753620
commit
f42924cd3b
2 changed files with 7 additions and 2 deletions
|
@ -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)));
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn router() -> Router {
|
|||
}
|
||||
|
||||
async fn get_asset(Path((project, filename)): Path<(String, String)>) -> Result<(HeaderMap, Vec<u8>), 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<impl std::io::Read + std::io::Seek>, filename:
|
|||
|
||||
async fn upload_project(mut multipart: Multipart, _auth: Authed, Path(project): Path<String>) -> 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");
|
||||
|
|
Loading…
Reference in a new issue