Compare commits

..

No commits in common. "81604a7e94f20ec51e3f6b3b21ad4b347aedd347" and "5c6f02b9a55a4063af52589273d41038b20192c8" have entirely different histories.

5 changed files with 19 additions and 23 deletions

2
Cargo.lock generated
View file

@ -1249,7 +1249,7 @@ dependencies = [
[[package]] [[package]]
name = "mangadex-home" name = "mangadex-home"
version = "0.5.4" version = "0.5.3"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"arc-swap", "arc-swap",

17
src/cache/fs.rs vendored
View file

@ -121,16 +121,13 @@ pub(super) async fn read_file(
// parsed_metadata is either set or unset here. If it's set then we // parsed_metadata is either set or unset here. If it's set then we
// successfully decoded the data; otherwise the file is garbage. // successfully decoded the data; otherwise the file is garbage.
reader.map_or_else( if let Some(reader) = reader {
|| { let stream = CacheStream::Completed(ReaderStream::new(reader));
debug!("Reader was invalid, file is corrupt"); parsed_metadata.map(|metadata| Ok((stream, maybe_header, metadata)))
None } else {
}, debug!("Reader was invalid, file is corrupt");
|reader| { None
let stream = CacheStream::Completed(ReaderStream::new(reader)); }
parsed_metadata.map(|metadata| Ok((stream, maybe_header, metadata)))
},
)
} }
struct EncryptedReader<R> { struct EncryptedReader<R> {

View file

@ -73,7 +73,7 @@ impl<'a> From<(&'a ClientSecret, &Config)> for Request<'a> {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
#[serde(untagged)] #[serde(untagged)]
pub enum Response { pub enum Response {
Ok(Box<OkResponse>), Ok(OkResponse),
Error(ErrorResponse), Error(ErrorResponse),
} }

View file

@ -3,10 +3,10 @@ use std::sync::atomic::Ordering;
use actix_web::body::BoxBody; use actix_web::body::BoxBody;
use actix_web::error::ErrorNotFound; use actix_web::error::ErrorNotFound;
use actix_web::http::header::{HeaderValue, CONTENT_LENGTH, CONTENT_TYPE, LAST_MODIFIED}; use actix_web::http::header::{CONTENT_LENGTH, CONTENT_TYPE, LAST_MODIFIED, HeaderValue};
use actix_web::web::{Data, Path}; use actix_web::web::Path;
use actix_web::HttpResponseBuilder; use actix_web::HttpResponseBuilder;
use actix_web::{get, HttpRequest, HttpResponse, Responder}; use actix_web::{get, web::Data, HttpRequest, HttpResponse, Responder};
use base64::DecodeError; use base64::DecodeError;
use bytes::Bytes; use bytes::Bytes;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};

View file

@ -64,16 +64,15 @@ impl ServerState {
.token_key .token_key
.ok_or(ServerInitError::MissingTokenKey) .ok_or(ServerInitError::MissingTokenKey)
.and_then(|key| { .and_then(|key| {
base64::decode(&key) if let Some(key) = base64::decode(&key)
.ok() .ok()
.and_then(|k| PrecomputedKey::from_slice(&k)) .and_then(|k| PrecomputedKey::from_slice(&k))
.map_or_else( {
|| { Ok(key)
error!("Failed to parse token key: got {}", key); } else {
Err(ServerInitError::KeyParseError(key)) error!("Failed to parse token key: got {}", key);
}, Err(ServerInitError::KeyParseError(key))
Ok, }
)
})?; })?;
PREVIOUSLY_COMPROMISED.store(resp.compromised, Ordering::Release); PREVIOUSLY_COMPROMISED.store(resp.compromised, Ordering::Release);