remove duplicate route and move public argument to public_path(), fix #738
This commit is contained in:
parent
76da2c3050
commit
81c132cf66
@ -1,6 +1,5 @@
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
env,
|
||||
fs::File,
|
||||
io,
|
||||
process::exit,
|
||||
@ -17,7 +16,6 @@ use actix_web_httpauth::middleware::HttpAuthentication;
|
||||
use actix_web_static_files::ResourceFiles;
|
||||
|
||||
use log::*;
|
||||
use path_clean::PathClean;
|
||||
|
||||
use ffplayout::{
|
||||
api::routes::*,
|
||||
@ -173,18 +171,7 @@ async fn main() -> std::io::Result<()> {
|
||||
)
|
||||
.service(get_file);
|
||||
|
||||
if let Some(public) = &ARGS.public {
|
||||
// When public path is set as argument use this path for serving extra static files,
|
||||
// is useful for HLS stream etc.
|
||||
let absolute_path = if public.is_absolute() {
|
||||
public.to_path_buf()
|
||||
} else {
|
||||
env::current_dir().unwrap_or_default().join(public)
|
||||
}
|
||||
.clean();
|
||||
|
||||
web_app = web_app.service(Files::new("/", absolute_path));
|
||||
} else {
|
||||
if ARGS.public.is_none() {
|
||||
// When no public path is given as argument, use predefine keywords in path,
|
||||
// like /live; /preview; /public, or HLS extensions to recognize file should get from public folder
|
||||
web_app = web_app.service(get_public);
|
||||
|
@ -195,7 +195,22 @@ pub fn db_path() -> Result<&'static str, Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
pub fn public_path() -> PathBuf {
|
||||
let path = PathBuf::from("./ffplayout-frontend/.output/public/");
|
||||
if let Some(public) = &ARGS.public {
|
||||
// When public path is set as argument use this path for serving static files.
|
||||
// Works only when feature embed_frontend is not set.
|
||||
let absolute_path = if public.is_absolute() {
|
||||
public.to_path_buf()
|
||||
} else {
|
||||
env::current_dir().unwrap_or_default().join(public)
|
||||
}
|
||||
.clean();
|
||||
|
||||
return absolute_path;
|
||||
}
|
||||
|
||||
let path = env::current_dir()
|
||||
.unwrap_or_default()
|
||||
.join("frontend/.output/public/");
|
||||
|
||||
if cfg!(debug_assertions) && path.is_dir() {
|
||||
return path;
|
||||
|
2
frontend
2
frontend
@ -1 +1 @@
|
||||
Subproject commit de6a3f03fa6de3a92e390b90f12a36465a16b3fd
|
||||
Subproject commit bb7446850c683c3a4465c336e348476d3c8bb49c
|
Loading…
Reference in New Issue
Block a user