Compare commits
No commits in common. "886ae6308bab05fd95e032b60cedada2279c7e6c" and "011c479550087251e01f34f94097436320749a34" have entirely different histories.
886ae6308b
...
011c479550
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "noxis-cli"
|
||||
version = "0.2.7"
|
||||
version = "0.2.4"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "noxis-rs"
|
||||
version = "0.11.26"
|
||||
version = "0.11.10"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use log::{error, info};
|
||||
use log::{error, info, warn};
|
||||
use tokio::net::{ UnixStream, UnixListener };
|
||||
use anyhow::Result as DynResult;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use std::fs;
|
||||
use std::{fs, io::{Read, Write}, os::fd::AsFd, path::Path};
|
||||
use tokio::io::{ AsyncWriteExt, AsyncReadExt};
|
||||
use noxis_cli::Cli;
|
||||
|
||||
|
|
@ -18,7 +19,7 @@ use noxis_cli::Cli;
|
|||
///
|
||||
/// *depends on* : -
|
||||
///
|
||||
pub async fn init_cli_pipeline() -> anyhow::Result<()> {
|
||||
pub async fn init_cli_pipeline() -> DynResult<()> {
|
||||
let socket_path = "noxis.sock";
|
||||
let _ = fs::remove_file(socket_path);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ type SendersVec = Arc<Vec<Arc<mpsc::Sender<u8>>>>;
|
|||
///
|
||||
/// *depends on* : Sig, Signals
|
||||
///
|
||||
pub async fn set_valid_destructor(senders: SendersVec) -> anyhow::Result<()> {
|
||||
pub async fn set_valid_destructor(senders: SendersVec) -> Result<(), CustomError> {
|
||||
let (mut int, mut term, mut stop) = (
|
||||
Sig::new(Signals::Sigint, senders.clone()),
|
||||
Sig::new(Signals::Sigterm, senders.clone()),
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use tokio::time::Duration;
|
|||
///
|
||||
/// *depends on* : -
|
||||
///
|
||||
pub async fn create_watcher(filename: &str, path: &str) -> anyhow::Result<Inotify> {
|
||||
pub async fn create_watcher(filename: &str, path: &str) -> Result<Inotify, std::io::Error> {
|
||||
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>>>,
|
||||
) -> anyhow::Result<()> {
|
||||
) -> Result<(), CustomError> {
|
||||
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(anyhow::Error::msg("Process is frozen or stopped"));
|
||||
return Err(CustomError::Fatal);
|
||||
}
|
||||
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(anyhow::Error::msg("Process was stopped"));
|
||||
return Err(CustomError::Fatal);
|
||||
}
|
||||
"hold" => {
|
||||
if is_active(name).await {
|
||||
tx.send(2).await.unwrap();
|
||||
return Err(anyhow::Error::msg("Process was frozen"));
|
||||
return Err(CustomError::Fatal);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||
tx.send(101).await.unwrap();
|
||||
return Err(anyhow::Error::msg("Impermissible character or word in file trigger"));
|
||||
return Err(CustomError::Fatal);
|
||||
}
|
||||
}
|
||||
} else if is_active(name).await && !is_frozen(name).await {
|
||||
|
|
|
|||
Loading…
Reference in New Issue