diff --git a/noxis-rs/src/options/cli_pipeline.rs b/noxis-rs/src/options/cli_pipeline.rs index c31df72..0c13e22 100644 --- a/noxis-rs/src/options/cli_pipeline.rs +++ b/noxis-rs/src/options/cli_pipeline.rs @@ -1,8 +1,7 @@ -use log::{error, info, warn}; +use log::{error, info}; use tokio::net::{ UnixStream, UnixListener }; -use anyhow::Result as DynResult; use tokio::time::{sleep, Duration}; -use std::{fs, io::{Read, Write}, os::fd::AsFd, path::Path}; +use std::fs; use tokio::io::{ AsyncWriteExt, AsyncReadExt}; use noxis_cli::Cli; @@ -19,7 +18,7 @@ use noxis_cli::Cli; /// /// *depends on* : - /// -pub async fn init_cli_pipeline() -> DynResult<()> { +pub async fn init_cli_pipeline() -> anyhow::Result<()> { let socket_path = "noxis.sock"; let _ = fs::remove_file(socket_path); diff --git a/noxis-rs/src/options/signals.rs b/noxis-rs/src/options/signals.rs index 7604bde..f840510 100644 --- a/noxis-rs/src/options/signals.rs +++ b/noxis-rs/src/options/signals.rs @@ -22,7 +22,7 @@ type SendersVec = Arc>>>; /// /// *depends on* : Sig, Signals /// -pub async fn set_valid_destructor(senders: SendersVec) -> Result<(), CustomError> { +pub async fn set_valid_destructor(senders: SendersVec) -> anyhow::Result<()> { let (mut int, mut term, mut stop) = ( Sig::new(Signals::Sigint, senders.clone()), Sig::new(Signals::Sigterm, senders.clone()), diff --git a/noxis-rs/src/utils/files.rs b/noxis-rs/src/utils/files.rs index 639ced2..3d0dade 100644 --- a/noxis-rs/src/utils/files.rs +++ b/noxis-rs/src/utils/files.rs @@ -20,7 +20,7 @@ use tokio::time::Duration; /// /// *depends on* : - /// -pub async fn create_watcher(filename: &str, path: &str) -> Result { +pub async fn create_watcher(filename: &str, path: &str) -> anyhow::Result { let src = format!("{}{}", path, filename); let inotify: Inotify = Inotify::init()?; inotify.watches().add(&src, WatchMask::ALL_EVENTS)?; @@ -45,12 +45,12 @@ pub async fn file_handler( files: &[Files], tx: Arc>, watchers: Arc>>, -) -> Result<(), CustomError> { +) -> anyhow::Result<()> { for (i, file) in files.iter().enumerate() { // let src = format!("{}{}", file.src, file.filename); if check_file(&file.filename, &file.src).await.is_err() { if !is_active(name).await || is_frozen(name).await { - return Err(CustomError::Fatal); + return Err(anyhow::Error::msg("Process is frozen or stopped")); } match file.triggers.on_delete.as_str() { "stay" => { @@ -61,18 +61,18 @@ pub async fn file_handler( if is_active(name).await { tx.send(1).await.unwrap(); } - return Err(CustomError::Fatal); + return Err(anyhow::Error::msg("Process was stopped")); } "hold" => { if is_active(name).await { tx.send(2).await.unwrap(); - return Err(CustomError::Fatal); + return Err(anyhow::Error::msg("Process was frozen")); } } _ => { tokio::time::sleep(Duration::from_millis(50)).await; tx.send(101).await.unwrap(); - return Err(CustomError::Fatal); + return Err(anyhow::Error::msg("Impermissible character or word in file trigger")); } } } else if is_active(name).await && !is_frozen(name).await {