Skip to content
Snippets Groups Projects
Commit f9a60bf4 authored by 🥺's avatar 🥺 :transgender_flag: Committed by 🥺
Browse files

make database_backup_path a PathBuf

parent 5a434e7f
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ pub struct Config { ...@@ -42,7 +42,7 @@ pub struct Config {
#[serde(default = "default_database_backend")] #[serde(default = "default_database_backend")]
pub database_backend: String, pub database_backend: String,
pub database_path: PathBuf, pub database_path: PathBuf,
pub database_backup_path: Option<String>, pub database_backup_path: Option<PathBuf>,
#[serde(default = "default_database_backups_to_keep")] #[serde(default = "default_database_backups_to_keep")]
pub database_backups_to_keep: i16, pub database_backups_to_keep: i16,
#[serde(default = "default_db_cache_capacity_mb")] #[serde(default = "default_db_cache_capacity_mb")]
...@@ -257,8 +257,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -257,8 +257,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
("Database path", &self.database_path.to_string_lossy()), ("Database path", &self.database_path.to_string_lossy()),
( (
"Database backup path", "Database backup path",
match self.database_backup_path.as_ref() { match &self.database_backup_path {
Some(path) => path, Some(path) => path.to_str().unwrap(),
None => "", None => "",
}, },
), ),
......
...@@ -225,7 +225,7 @@ fn cleanup(&self) -> Result<()> { ...@@ -225,7 +225,7 @@ fn cleanup(&self) -> Result<()> {
fn backup(&self) -> Result<(), Box<dyn std::error::Error>> { fn backup(&self) -> Result<(), Box<dyn std::error::Error>> {
let path = self.config.database_backup_path.as_ref(); let path = self.config.database_backup_path.as_ref();
if path.is_none() || path.is_some_and(String::is_empty) { if path.is_none() || path.is_some_and(|path| path.as_os_str().is_empty()) {
return Ok(()); return Ok(());
} }
...@@ -260,8 +260,10 @@ fn backup(&self) -> Result<(), Box<dyn std::error::Error>> { ...@@ -260,8 +260,10 @@ fn backup(&self) -> Result<(), Box<dyn std::error::Error>> {
fn backup_list(&self) -> Result<String> { fn backup_list(&self) -> Result<String> {
let path = self.config.database_backup_path.as_ref(); let path = self.config.database_backup_path.as_ref();
if path.is_none() || path.is_some_and(String::is_empty) { if path.is_none() || path.is_some_and(|path| path.as_os_str().is_empty()) {
return Ok("Configure database_backup_path to enable backups".to_owned()); return Ok(
"Configure database_backup_path to enable backups, or the path specified is not valid".to_owned(),
);
} }
let mut res = String::new(); let mut res = String::new();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment