diff options
author | Vika <vika@fireburn.ru> | 2021-09-27 17:41:19 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2021-09-27 17:41:19 +0300 |
commit | 340965b1f5f810414742076501a2fff8a39db674 (patch) | |
tree | 08c57cabb9ebdcc4f66244b069f415497ba518b2 /src | |
parent | 5e291ca70ca2712696fa5378894e4204679a5f7d (diff) | |
download | kittybox-340965b1f5f810414742076501a2fff8a39db674.tar.zst |
Code cleanup and Cargo.lock updates
Diffstat (limited to 'src')
-rw-r--r-- | src/database/file/mod.rs | 5 | ||||
-rw-r--r-- | src/database/mod.rs | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/database/file/mod.rs b/src/database/file/mod.rs index 78b67fb..acbb44b 100644 --- a/src/database/file/mod.rs +++ b/src/database/file/mod.rs @@ -1,5 +1,5 @@ use async_std::fs::{File, OpenOptions}; -use async_std::io::{ErrorKind as IOErrorKind, BufReader}; +use async_std::io::{ErrorKind as IOErrorKind}; use async_std::io::prelude::*; use async_std::task::spawn_blocking; use async_trait::async_trait; @@ -177,6 +177,7 @@ pub struct FileStorage { } impl FileStorage { + /// Create a new storage wrapping a folder specified by root_dir. pub async fn new(root_dir: PathBuf) -> Result<Self> { // TODO check if the dir is writable Ok(Self { root_dir }) @@ -237,7 +238,7 @@ impl Storage for FileStorage { .create_new(true) .open(&path) .await?; - + let mut lock = get_lockable_file(f).await; let mut guard = lock.write()?; diff --git a/src/database/mod.rs b/src/database/mod.rs index 0b97c24..7c67e42 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -7,8 +7,7 @@ use serde::{Deserialize, Serialize}; mod redis; #[cfg(redis)] pub use crate::database::redis::RedisStorage; -#[cfg(redis)] -#[cfg(test)] +#[cfg(all(redis, test))] pub use redis::tests::{get_redis_instance, RedisInstance}; mod file; @@ -36,6 +35,8 @@ pub struct StorageError { source: Option<Box<dyn std::error::Error>>, kind: ErrorKind, } +// XXX figure out what makes this un-sendable by default +// and if it's sound to mark StorageError as Send & Sync unsafe impl Send for StorageError {} unsafe impl Sync for StorageError {} impl From<StorageError> for tide::Response { |