mirror of
https://github.com/speatzle/nfsense.git
synced 2025-09-13 15:19:08 +00:00
Start using anyhow
This commit is contained in:
parent
8c82d26fcf
commit
f951718241
3 changed files with 7 additions and 3 deletions
|
@ -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
Add a link
Reference in a new issue