make result folders

Former-commit-id: d3e2d82ebe0462eb06c2d35cd6cbfe984aae6a7a
This commit is contained in:
Daniel 2020-05-02 00:06:12 +02:00 committed by Daniel Olsen
parent 2b4c5820c0
commit 121b1df927

View File

@ -110,8 +110,12 @@ fn upload(id: Uuid, video: Data, shared: State<SharedState>) -> Result<String, s
else { else {
let list = shared.jobs.lock().unwrap(); let list = shared.jobs.lock().unwrap();
let job = list.get(&id).unwrap(); let job = list.get(&id).unwrap();
let filename = format!("results/{jobset}/{name}.webm", jobset = job.jobset, name = job.description.file_name);
let folder = format!("results/{jobset}", jobset = job.jobset);
let filename = format!("{folder}/{name}.{id}.webm", folder = folder, name = job.description.file_name, id = id);
let url = format!("{host}/{id}\n", host = "https://av1.dodsorf.as", id = id); let url = format!("{host}/{id}\n", host = "https://av1.dodsorf.as", id = id);
std::fs::create_dir_all(&folder)?;
video.stream_to_file(Path::new(&filename))?; video.stream_to_file(Path::new(&filename))?;
Ok(url) Ok(url)
} }
@ -131,4 +135,4 @@ fn main() {
.mount("/", StaticFiles::from("src/static")) // switch to templates or something cause this is dumb .mount("/", StaticFiles::from("src/static")) // switch to templates or something cause this is dumb
.mount("/", routes![index, version, get_jobs, get_job, request_job, edit_status, add_job, upload]) .mount("/", routes![index, version, get_jobs, get_job, request_job, edit_status, add_job, upload])
.launch(); .launch();
} }