simplify code
This commit is contained in:
parent
21e9a27027
commit
f1fc19547a
@ -138,17 +138,15 @@ pub async fn rename_file(id: i64, move_object: &MoveObject) -> Result<MoveObject
|
||||
.normalize()
|
||||
.to_string();
|
||||
|
||||
if !source_path.starts_with(&relativ_path) {
|
||||
source_path = path.join(source);
|
||||
} else {
|
||||
source_path = path.join(source_path.strip_prefix(&relativ_path).unwrap());
|
||||
}
|
||||
source_path = match source_path.starts_with(&relativ_path) {
|
||||
true => path.join(source_path.strip_prefix(&relativ_path).unwrap()),
|
||||
false => path.join(source),
|
||||
};
|
||||
|
||||
if !target_path.starts_with(&relativ_path) {
|
||||
target_path = path.join(target);
|
||||
} else {
|
||||
target_path = path.join(target_path.strip_prefix(relativ_path).unwrap());
|
||||
}
|
||||
target_path = match target_path.starts_with(&relativ_path) {
|
||||
true => path.join(target_path.strip_prefix(relativ_path).unwrap()),
|
||||
false => path.join(target),
|
||||
};
|
||||
|
||||
if !source_path.exists() {
|
||||
return Err(ServiceError::BadRequest("Source file not exist!".into()));
|
||||
@ -273,7 +271,6 @@ pub async fn upload(id: i64, mut payload: Multipart) -> Result<HttpResponse, Ser
|
||||
return Err(ServiceError::BadRequest("Target already exists!".into()));
|
||||
}
|
||||
|
||||
// File::create is blocking operation, use threadpool
|
||||
let mut f = web::block(|| std::fs::File::create(filepath)).await??;
|
||||
|
||||
while let Some(chunk) = field.try_next().await? {
|
||||
|
@ -102,12 +102,11 @@ fn main() {
|
||||
|
||||
status_file(&config.general.stat_file, &playout_stat);
|
||||
|
||||
if &config.out.mode.to_lowercase() == "hls" {
|
||||
match config.out.mode.to_lowercase().as_str() {
|
||||
// write files/playlist to HLS m3u8 playlist
|
||||
write_hls(&config, play_control, playout_stat, proc_control);
|
||||
} else {
|
||||
"hls" => write_hls(&config, play_control, playout_stat, proc_control),
|
||||
// play on desktop or stream to a remote target
|
||||
player(&config, play_control, playout_stat, proc_control);
|
||||
_ => player(&config, play_control, playout_stat, proc_control),
|
||||
}
|
||||
|
||||
info!("Playout done...");
|
||||
|
@ -189,7 +189,7 @@ impl PlayoutConfig {
|
||||
println!(
|
||||
"{config_path:?} doesn't exists!\nPut \"ffplayout.yml\" in \"/etc/playout/\" or beside the executable!"
|
||||
);
|
||||
process::exit(0x0100);
|
||||
process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -184,10 +184,9 @@ pub fn read_json(
|
||||
validate_playlist(list_clone, is_terminated, config_clone)
|
||||
});
|
||||
|
||||
if config.playlist.infinit {
|
||||
return loop_playlist(config, current_file, playlist);
|
||||
} else {
|
||||
return set_defaults(playlist, current_file, start_sec);
|
||||
match config.playlist.infinit {
|
||||
true => return loop_playlist(config, current_file, playlist),
|
||||
false => return set_defaults(playlist, current_file, start_sec),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -206,10 +205,9 @@ pub fn read_json(
|
||||
|
||||
thread::spawn(move || validate_playlist(list_clone, is_terminated, config_clone));
|
||||
|
||||
if config.playlist.infinit {
|
||||
return loop_playlist(config, current_file, playlist);
|
||||
} else {
|
||||
return set_defaults(playlist, current_file, start_sec);
|
||||
match config.playlist.infinit {
|
||||
true => return loop_playlist(config, current_file, playlist),
|
||||
false => return set_defaults(playlist, current_file, start_sec),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user