Compare commits

...

2 Commits

Author SHA1 Message Date
prplV 886ae6308b versions change 2025-03-31 10:08:50 -04:00
prplV 8f1214bd9a refactor 2025-03-31 10:06:18 -04:00
5 changed files with 12 additions and 13 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "noxis-cli" name = "noxis-cli"
version = "0.2.4" version = "0.2.7"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "noxis-rs" name = "noxis-rs"
version = "0.11.10" version = "0.11.26"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,8 +1,7 @@
use log::{error, info, warn}; use log::{error, info};
use tokio::net::{ UnixStream, UnixListener }; use tokio::net::{ UnixStream, UnixListener };
use anyhow::Result as DynResult;
use tokio::time::{sleep, Duration}; 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 tokio::io::{ AsyncWriteExt, AsyncReadExt};
use noxis_cli::Cli; use noxis_cli::Cli;
@ -19,7 +18,7 @@ use noxis_cli::Cli;
/// ///
/// *depends on* : - /// *depends on* : -
/// ///
pub async fn init_cli_pipeline() -> DynResult<()> { pub async fn init_cli_pipeline() -> anyhow::Result<()> {
let socket_path = "noxis.sock"; let socket_path = "noxis.sock";
let _ = fs::remove_file(socket_path); let _ = fs::remove_file(socket_path);

View File

@ -22,7 +22,7 @@ type SendersVec = Arc<Vec<Arc<mpsc::Sender<u8>>>>;
/// ///
/// *depends on* : Sig, Signals /// *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) = ( let (mut int, mut term, mut stop) = (
Sig::new(Signals::Sigint, senders.clone()), Sig::new(Signals::Sigint, senders.clone()),
Sig::new(Signals::Sigterm, senders.clone()), Sig::new(Signals::Sigterm, senders.clone()),

View File

@ -20,7 +20,7 @@ use tokio::time::Duration;
/// ///
/// *depends on* : - /// *depends on* : -
/// ///
pub async fn create_watcher(filename: &str, path: &str) -> Result<Inotify, std::io::Error> { pub async fn create_watcher(filename: &str, path: &str) -> anyhow::Result<Inotify> {
let src = format!("{}{}", path, filename); let src = format!("{}{}", path, filename);
let inotify: Inotify = Inotify::init()?; let inotify: Inotify = Inotify::init()?;
inotify.watches().add(&src, WatchMask::ALL_EVENTS)?; inotify.watches().add(&src, WatchMask::ALL_EVENTS)?;
@ -45,12 +45,12 @@ pub async fn file_handler(
files: &[Files], files: &[Files],
tx: Arc<mpsc::Sender<u8>>, tx: Arc<mpsc::Sender<u8>>,
watchers: Arc<tokio::sync::Mutex<Vec<Inotify>>>, watchers: Arc<tokio::sync::Mutex<Vec<Inotify>>>,
) -> Result<(), CustomError> { ) -> anyhow::Result<()> {
for (i, file) in files.iter().enumerate() { for (i, file) in files.iter().enumerate() {
// let src = format!("{}{}", file.src, file.filename); // let src = format!("{}{}", file.src, file.filename);
if check_file(&file.filename, &file.src).await.is_err() { if check_file(&file.filename, &file.src).await.is_err() {
if !is_active(name).await || is_frozen(name).await { 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() { match file.triggers.on_delete.as_str() {
"stay" => { "stay" => {
@ -61,18 +61,18 @@ pub async fn file_handler(
if is_active(name).await { if is_active(name).await {
tx.send(1).await.unwrap(); tx.send(1).await.unwrap();
} }
return Err(CustomError::Fatal); return Err(anyhow::Error::msg("Process was stopped"));
} }
"hold" => { "hold" => {
if is_active(name).await { if is_active(name).await {
tx.send(2).await.unwrap(); 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; tokio::time::sleep(Duration::from_millis(50)).await;
tx.send(101).await.unwrap(); 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 { } else if is_active(name).await && !is_frozen(name).await {