jobsets and folders
Former-commit-id: 42d81df7327918aaace728aad803162144734be5
This commit is contained in:
parent
c5a165cfe3
commit
4c5d8455fb
10
src/main.rs
10
src/main.rs
@ -108,7 +108,9 @@ fn upload(id: Uuid, video: Data, shared: State<SharedState>) -> Result<String, s
|
||||
Err(std::io::Error::new(std::io::ErrorKind::NotFound, "Job not found"))
|
||||
}
|
||||
else {
|
||||
let filename = format!("results/{name}.{id}.webm", name = shared.jobs.lock().unwrap().get(&id).unwrap().description.file_name, id = id);
|
||||
let list = shared.jobs.lock().unwrap();
|
||||
let job = list.get(&id).unwrap();
|
||||
let filename = format!("results/{jobset}/{name}.{id}.webm", jobset = job.jobset, name = job.description.file_name, id = id);
|
||||
let url = format!("{host}/{id}\n", host = "https://av1.dodsorf.as", id = id);
|
||||
video.stream_to_file(Path::new(&filename))?;
|
||||
Ok(url)
|
||||
@ -116,11 +118,11 @@ fn upload(id: Uuid, video: Data, shared: State<SharedState>) -> Result<String, s
|
||||
}
|
||||
|
||||
|
||||
#[post("/add_job", format = "json", data = "<message>")]
|
||||
fn add_job(message: Json<workunit::WDesc>, shared: State<SharedState>) {
|
||||
#[post("/add_job/<jobset>", format = "json", data = "<message>")]
|
||||
fn add_job(message: Json<workunit::WDesc>, jobset: String, shared: State<SharedState>) {
|
||||
let job = message.into_inner();
|
||||
let id = uuid::Uuid::new_v4();
|
||||
shared.jobs.lock().unwrap().insert(id, WUnit::new(id, job));
|
||||
shared.jobs.lock().unwrap().insert(id, WUnit::new(id, jobset, job));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -6,13 +6,21 @@ use std::net::IpAddr;
|
||||
#[derive(Default, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct WUnit {
|
||||
pub id: Uuid,
|
||||
pub jobset: String,
|
||||
pub description: WDesc,
|
||||
pub status: EStatus
|
||||
}
|
||||
impl WUnit {
|
||||
pub fn new(id: Uuid, description: WDesc) -> Self {
|
||||
pub fn new(id: Uuid, _jobset: String, description: WDesc) -> Self {
|
||||
let jobset: String = _jobset.chars()
|
||||
.map(|x| match x {
|
||||
'.' => '_',
|
||||
'/' => '-',
|
||||
_ => x
|
||||
}).collect();
|
||||
WUnit {
|
||||
id: id,
|
||||
jobset: jobset,
|
||||
description: description,
|
||||
status: EStatus::Queued
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user