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]
name = "noxis-cli"
version = "0.2.4"
version = "0.2.7"
edition = "2021"
[dependencies]

View File

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

View File

@ -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);

View File

@ -22,7 +22,7 @@ type SendersVec = Arc<Vec<Arc<mpsc::Sender<u8>>>>;
///
/// *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()),

View File

@ -20,7 +20,7 @@ use tokio::time::Duration;
///
/// *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 inotify: Inotify = Inotify::init()?;
inotify.watches().add(&src, WatchMask::ALL_EVENTS)?;
@ -45,12 +45,12 @@ pub async fn file_handler(
files: &[Files],
tx: Arc<mpsc::Sender<u8>>,
watchers: Arc<tokio::sync::Mutex<Vec<Inotify>>>,
) -> 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 {