From f013a90179499e4a390127b3e805866ece70be74 Mon Sep 17 00:00:00 2001 From: Sayan Nandan Date: Thu, 6 May 2021 19:54:49 +0530 Subject: [PATCH] Change snapshot directory to data/snapshots --- server/src/config/mod.rs | 3 ++- server/src/dbnet/mod.rs | 12 +----------- server/src/diskstore/snapshot.rs | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/server/src/config/mod.rs b/server/src/config/mod.rs index cfb4a1e6..2a131be9 100644 --- a/server/src/config/mod.rs +++ b/server/src/config/mod.rs @@ -26,6 +26,7 @@ //! This module provides tools to handle configuration files and settings +use crate::diskstore::snapshot::DIR_SNAPSHOT; #[cfg(test)] use libsky::TResult; use serde::Deserialize; @@ -410,7 +411,7 @@ pub fn get_config_file_or_return_cfg() -> Result match e.kind() { ErrorKind::AlreadyExists => (), _ => { - log::error!("Failed to create snapshot directories: '{}'", e); - process::exit(0x100); - } - }, - } - match fs::create_dir("./data") { - Ok(_) => (), - Err(e) => match e.kind() { - ErrorKind::AlreadyExists => (), - _ => { - log::error!("Failed to create snapshot directories: '{}'", e); + log::error!("Failed to create data directories: '{}'", e); process::exit(0x100); } }, diff --git a/server/src/diskstore/snapshot.rs b/server/src/diskstore/snapshot.rs index e07c0b9f..f525c38a 100644 --- a/server/src/diskstore/snapshot.rs +++ b/server/src/diskstore/snapshot.rs @@ -46,13 +46,13 @@ lazy_static::lazy_static! { /// ``` static ref SNAP_MATCH: Regex = Regex::new("^\\d{4}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])(-)(?:(?:([01]?\\d|2[0-3]))?([0-5]?\\d))?([0-5]?\\d)(.snapshot)$").unwrap(); /// The directory for remote snapshots - pub static ref DIR_REMOTE_SNAPSHOT: PathBuf = PathBuf::from("./snapshots/remote"); + pub static ref DIR_REMOTE_SNAPSHOT: PathBuf = PathBuf::from("./data/snapshots/remote"); } /// The default snapshot directory /// /// This is currently a `snapshot` directory under the current directory -pub const DIR_SNAPSHOT: &'static str = "snapshots"; +pub const DIR_SNAPSHOT: &'static str = "data/snapshots"; /// The default snapshot count is 12, assuming that the user would take a snapshot /// every 2 hours (or 7200 seconds) const DEF_SNAPSHOT_COUNT: usize = 12;