diff options
author | Vika <vika@fireburn.ru> | 2022-05-01 13:56:13 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2022-05-01 13:56:13 +0300 |
commit | 9a6ad0e67b52e419c8a1c59c9cd187d1b85cd9f8 (patch) | |
tree | 0143dbd02ff13c8a0750019f45e0ab979159b891 /src/database/file | |
parent | 0a62fe61acdb5dda4e28322ed96c074240bbdc44 (diff) | |
download | kittybox-9a6ad0e67b52e419c8a1c59c9cd187d1b85cd9f8.tar.zst |
chore: code cleanup
Diffstat (limited to 'src/database/file')
-rw-r--r-- | src/database/file/mod.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/database/file/mod.rs b/src/database/file/mod.rs index 53dea04..853240a 100644 --- a/src/database/file/mod.rs +++ b/src/database/file/mod.rs @@ -5,9 +5,6 @@ use tokio::fs::{File, OpenOptions}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::task::spawn_blocking; use async_trait::async_trait; -/*use futures_util::stream; -use futures_util::StreamExt; -use futures_util::TryStreamExt;*/ use futures::{stream, StreamExt, TryStreamExt}; use log::debug; use serde_json::json; @@ -111,7 +108,7 @@ fn url_to_path(root: &Path, url: &str) -> PathBuf { fn url_to_relative_path(url: &str) -> relative_path::RelativePathBuf { let url = warp::http::Uri::try_from(url).expect("Couldn't parse a URL"); let mut path = relative_path::RelativePathBuf::new(); - path.push(url.authority().unwrap().to_string() + &url.path().to_string() + ".json"); + path.push(url.authority().unwrap().to_string() + url.path() + ".json"); path } @@ -402,12 +399,11 @@ impl Storage for FileStorage { let mut content = String::new(); file.read_to_string(&mut content).await?; drop(file); - let mut channels: Vec<super::MicropubChannel>; - if !content.is_empty() { - channels = serde_json::from_str(&content)?; + let mut channels: Vec<super::MicropubChannel> = if !content.is_empty() { + serde_json::from_str(&content)? } else { - channels = Vec::default(); - } + Vec::default() + }; channels.push(super::MicropubChannel { uid: key.to_string(), @@ -614,6 +610,6 @@ impl Storage for FileStorage { tempfile.write_all(serde_json::to_string(&settings)?.as_bytes()).await?; drop(tempfile); tokio::fs::rename(temppath, path).await?; - Result::Ok(()) + Ok(()) } } |