fix clippy errors

This commit is contained in:
jb-alvarado 2024-04-25 13:00:13 +02:00
parent d0244da05e
commit 09d6e279d0
6 changed files with 22 additions and 22 deletions

8
Cargo.lock generated
View File

@ -1293,7 +1293,7 @@ checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984"
[[package]]
name = "ffplayout"
version = "0.21.3"
version = "0.22.0"
dependencies = [
"chrono",
"clap",
@ -1315,7 +1315,7 @@ dependencies = [
[[package]]
name = "ffplayout-api"
version = "0.21.3"
version = "0.22.0"
dependencies = [
"actix-files",
"actix-multipart",
@ -1358,7 +1358,7 @@ dependencies = [
[[package]]
name = "ffplayout-lib"
version = "0.21.3"
version = "0.22.0"
dependencies = [
"chrono",
"crossbeam-channel",
@ -3578,7 +3578,7 @@ dependencies = [
[[package]]
name = "tests"
version = "0.21.3"
version = "0.22.0"
dependencies = [
"chrono",
"crossbeam-channel",

View File

@ -4,7 +4,7 @@ default-members = ["ffplayout-api", "ffplayout-engine", "tests"]
resolver = "2"
[workspace.package]
version = "0.21.3"
version = "0.22.0"
license = "GPL-3.0"
repository = "https://github.com/ffplayout/ffplayout"
authors = ["Jonathan Baecker <jonbae77@gmail.com>"]

View File

@ -1,9 +1,4 @@
use std::{
collections::HashSet,
env,
process::exit,
sync::{Arc, Mutex},
};
use std::{collections::HashSet, env, process::exit, sync::Arc};
use actix_files::Files;
use actix_web::{
@ -17,6 +12,7 @@ use actix_web_static_files::ResourceFiles;
use path_clean::PathClean;
use simplelog::*;
use tokio::sync::Mutex;
use ffplayout_api::{
api::{auth, routes::*},

View File

@ -1,9 +1,9 @@
use std::{
collections::HashSet,
sync::Mutex,
time::{Duration, SystemTime},
};
use tokio::sync::Mutex;
use uuid::Uuid;
use crate::utils::errors::ServiceError;
@ -26,6 +26,12 @@ impl UuidData {
}
}
impl Default for UuidData {
fn default() -> Self {
Self::new()
}
}
pub struct AuthState {
pub uuids: Mutex<HashSet<UuidData>>,
}

View File

@ -28,7 +28,7 @@ impl User {
#[post("/generate-uuid")]
#[protect(any("Role::Admin", "Role::User"), ty = "Role")]
async fn generate_uuid(data: web::Data<AuthState>) -> Result<impl Responder, ServiceError> {
let mut uuids = data.uuids.lock().map_err(|e| e.to_string())?;
let mut uuids = data.uuids.lock().await;
let new_uuid = UuidData::new();
let user_auth = User::new(String::new(), new_uuid.uuid.to_string());
@ -49,7 +49,7 @@ async fn validate_uuid(
data: web::Data<AuthState>,
user: web::Query<User>,
) -> Result<impl Responder, ServiceError> {
let mut uuids = data.uuids.lock().map_err(|e| e.to_string())?;
let mut uuids = data.uuids.lock().await;
match check_uuid(&mut uuids, user.uuid.as_str()) {
Ok(s) => Ok(web::Json(s)),
@ -70,11 +70,9 @@ async fn event_stream(
id: web::Path<i32>,
user: web::Query<User>,
) -> Result<impl Responder, ServiceError> {
let mut uuids = data.uuids.lock().map_err(|e| e.to_string())?;
let mut uuids = data.uuids.lock().await;
if let Err(e) = check_uuid(&mut uuids, user.uuid.as_str()) {
return Err(e);
}
check_uuid(&mut uuids, user.uuid.as_str())?;
let (config, _) = playout_config(&pool.clone().into_inner(), &id).await?;

View File

@ -1,4 +1,4 @@
// use std::cmp;
use std::fmt;
use local_ip_address::list_afinet_netifas;
use serde::Serialize;
@ -71,9 +71,9 @@ pub struct SystemStat {
pub system: MySystem,
}
impl SystemStat {
pub fn to_string(&self) -> String {
serde_json::to_string(&self).unwrap()
impl fmt::Display for SystemStat {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", serde_json::to_string(self).unwrap())
}
}