mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 10:38:20 +00:00
Start using anyhow
This commit is contained in:
parent
8c82d26fcf
commit
f951718241
3 changed files with 7 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -688,6 +688,7 @@ dependencies = [
|
|||
name = "nfsense"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"axum",
|
||||
"ipnet",
|
||||
|
|
|
@ -6,6 +6,7 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.75"
|
||||
async-trait = "0.1.74"
|
||||
axum = "0.6.20"
|
||||
ipnet = { version = "2.8.0", features = ["serde"] }
|
||||
|
|
|
@ -3,9 +3,10 @@ use validator::Validate;
|
|||
use crate::api::ApiError;
|
||||
|
||||
use super::definitions::config::Config;
|
||||
use anyhow::{Context, Result};
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
use std::{io, result::Result};
|
||||
|
||||
use pwhash::sha512_crypt;
|
||||
|
||||
|
@ -74,11 +75,12 @@ impl ConfigManager {
|
|||
self.shared_data.lock().unwrap().pending_config.clone()
|
||||
}
|
||||
|
||||
pub fn apply_pending_changes(&mut self) -> Result<(), ConfigError> {
|
||||
pub fn apply_pending_changes(&mut self) -> Result<()> {
|
||||
let mut data = self.shared_data.lock().unwrap();
|
||||
// TODO run Apply functions
|
||||
// TODO Revert on Apply Failure and Return
|
||||
write_config_to_file(CURRENT_CONFIG_PATH, data.pending_config.clone())?;
|
||||
write_config_to_file(CURRENT_CONFIG_PATH, data.pending_config.clone())
|
||||
.context("Writing Config to file".to_string())?;
|
||||
// TODO revert if config save fails
|
||||
// TODO Remove Pending Config File
|
||||
data.current_config = data.pending_config.clone();
|
||||
|
|
Loading…
Add table
Reference in a new issue