From 54914782c7632e041919746e80d3f802f6601a63 Mon Sep 17 00:00:00 2001 From: Vika Date: Wed, 23 Mar 2022 05:01:14 +0300 Subject: Make the settings in the database a strong type --- src/database/file/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/database/file/mod.rs') diff --git a/src/database/file/mod.rs b/src/database/file/mod.rs index af07c0c..b3856a6 100644 --- a/src/database/file/mod.rs +++ b/src/database/file/mod.rs @@ -1,5 +1,5 @@ //#![warn(clippy::unwrap_used)] -use crate::database::{filter_post, ErrorKind, Result, Storage, StorageError}; +use crate::database::{filter_post, ErrorKind, Result, Storage, StorageError, Settings}; use std::fs::{File, OpenOptions}; use std::io::{ErrorKind as IOErrorKind, Seek, SeekFrom, Read, Write}; use std::time::Duration; @@ -387,6 +387,10 @@ impl Storage for FileStorage { { symlink_result = std::os::windows::fs::symlink_file(relative, link); } + #[cfg(all(not(unix), not(windows)))] + { + compile_error!("Don't know how to create symlinks on non-unix non-windows platform"); + } if let Err(e) = symlink_result { Err(e.into()) } else { @@ -596,7 +600,7 @@ impl Storage for FileStorage { } } - async fn get_setting(&self, setting: &'_ str, user: &'_ str) -> Result { + async fn get_setting(&self, setting: Settings, user: &'_ str) -> Result { log::debug!("User for getting settings: {}", user); let url = warp::http::Uri::try_from(user).expect("Couldn't parse a URL"); let mut path = relative_path::RelativePathBuf::new(); @@ -626,7 +630,7 @@ impl Storage for FileStorage { )).await?.unwrap() } - async fn set_setting(&self, setting: &'_ str, user: &'_ str, value: &'_ str) -> Result<()> { + async fn set_setting(&self, setting: Settings, user: &'_ str, value: &'_ str) -> Result<()> { let url = warp::http::Uri::try_from(user).expect("Couldn't parse a URL"); let mut path = relative_path::RelativePathBuf::new(); path.push(url.authority().unwrap().to_string()); -- cgit 1.4.1