Merge pull request #149 from jb-alvarado/master

less strict errors, deb installer: create folder and permission
This commit is contained in:
jb-alvarado 2022-07-07 21:26:34 +02:00 committed by GitHub
commit be701022fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 6 deletions

2
Cargo.lock generated
View File

@ -1027,7 +1027,7 @@ dependencies = [
[[package]] [[package]]
name = "ffplayout-api" name = "ffplayout-api"
version = "0.4.0" version = "0.4.1"
dependencies = [ dependencies = [
"actix-multipart", "actix-multipart",
"actix-web", "actix-web",

9
debian/postinst vendored
View File

@ -16,3 +16,12 @@ if [ ! -d "/usr/share/ffplayout/db" ]; then
systemctl daemon-reload systemctl daemon-reload
fi fi
fi fi
if [ ! -d "/var/log/ffplayout" ]; then
mkdir /var/log/ffplayout
if id "www-data" &>/dev/null; then
chown www-data. /var/log/ffplayout
chown -R www-data. /etc/ffplayout
fi
fi

View File

@ -4,7 +4,7 @@ description = "Rest API for ffplayout"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Jonathan Baecker jonbae77@gmail.com"] authors = ["Jonathan Baecker jonbae77@gmail.com"]
readme = "README.md" readme = "README.md"
version = "0.4.0" version = "0.4.1"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -130,7 +130,7 @@ where
Ok(result) => Ok(result), Ok(result) => Ok(result),
Err(e) => { Err(e) => {
error!("{e:?}"); error!("{e:?}");
Err(ServiceError::BadRequest(e.to_string())) Err(ServiceError::ServiceUnavailable(e.to_string()))
} }
} }
} }

View File

@ -17,6 +17,9 @@ pub enum ServiceError {
#[display(fmt = "NoContent: {}", _0)] #[display(fmt = "NoContent: {}", _0)]
NoContent(String), NoContent(String),
#[display(fmt = "ServiceUnavailable: {}", _0)]
ServiceUnavailable(String),
} }
// impl ResponseError trait allows to convert our errors into http responses with appropriate data // impl ResponseError trait allows to convert our errors into http responses with appropriate data
@ -30,6 +33,9 @@ impl ResponseError for ServiceError {
ServiceError::Conflict(ref message) => HttpResponse::Conflict().json(message), ServiceError::Conflict(ref message) => HttpResponse::Conflict().json(message),
ServiceError::Unauthorized => HttpResponse::Unauthorized().json("No Permission!"), ServiceError::Unauthorized => HttpResponse::Unauthorized().json("No Permission!"),
ServiceError::NoContent(ref message) => HttpResponse::NoContent().json(message), ServiceError::NoContent(ref message) => HttpResponse::NoContent().json(message),
ServiceError::ServiceUnavailable(ref message) => {
HttpResponse::ServiceUnavailable().json(message)
}
} }
} }
} }
@ -54,7 +60,7 @@ impl From<actix_multipart::MultipartError> for ServiceError {
impl From<std::io::Error> for ServiceError { impl From<std::io::Error> for ServiceError {
fn from(err: std::io::Error) -> ServiceError { fn from(err: std::io::Error) -> ServiceError {
ServiceError::BadRequest(err.to_string()) ServiceError::NoContent(err.to_string())
} }
} }

View File

@ -93,7 +93,7 @@ pub async fn browser(id: i64, path_obj: &PathObject) -> Result<PathObject, Servi
Ok(p) => p.filter_map(|r| r.ok()).collect(), Ok(p) => p.filter_map(|r| r.ok()).collect(),
Err(e) => { Err(e) => {
error!("{e} in {}", path_obj.source); error!("{e} in {}", path_obj.source);
return Err(ServiceError::InternalServerError); return Err(ServiceError::NoContent(e.to_string()));
} }
}; };

View File

@ -217,7 +217,7 @@ pub async fn read_log_file(channel_id: &i64, date: &str) -> Result<String, Servi
} }
} }
Err(ServiceError::BadRequest( Err(ServiceError::NoContent(
"Requested log file not exists, or not readable.".to_string(), "Requested log file not exists, or not readable.".to_string(),
)) ))
} }