Use question mark in get

This commit is contained in:
Edward Shen 2021-04-18 17:25:28 -04:00
parent 2650a96d16
commit 525aef91bf
Signed by: edward
GPG key ID: 19182661E818369F
2 changed files with 7 additions and 10 deletions

View file

@ -32,7 +32,7 @@ simple_logger = "1"
sodiumoxide = "0.2"
ssri = "5"
thiserror = "1"
tokio = { version = "1", features = [ "full" ] }
tokio = { version = "1", features = [ "full", "parking_lot" ] }
url = { version = "2", features = [ "serde" ] }
[profile.release]

15
src/cache/low_mem.rs vendored
View file

@ -33,15 +33,12 @@ impl Cache for LowMemCache {
&mut self,
key: &CacheKey,
) -> Option<Result<(CacheStream, &ImageMetadata), CacheError>> {
if let Some(metadata) = self.on_disk.get(key) {
let path = self.disk_path.clone().join(PathBuf::from(key.clone()));
super::fs::read_file(&path).await.map(|res| {
res.map(|stream| (CacheStream::Fs(stream), metadata))
.map_err(Into::into)
})
} else {
None
}
let metadata = self.on_disk.get(key)?;
let path = self.disk_path.clone().join(PathBuf::from(key.clone()));
super::fs::read_file(&path).await.map(|res| {
res.map(|stream| (CacheStream::Fs(stream), metadata))
.map_err(Into::into)
})
}
async fn put(