More debugging

This commit is contained in:
Edward Shen 2021-07-13 23:12:29 -04:00
parent 6ac8582183
commit 94375b185f
Signed by: edward
GPG key ID: 19182661E818369F
3 changed files with 28 additions and 36 deletions

View file

@ -9,9 +9,9 @@ description = "A MangaDex@Home implementation in Rust."
repository = "https://github.com/edward-shen/mangadex-home-rs" repository = "https://github.com/edward-shen/mangadex-home-rs"
[profile.release] [profile.release]
lto = true # lto = true
codegen-units = 1 # codegen-units = 1
# debug = 1 debug = 1
[dependencies] [dependencies]
actix-web = { version = "4.0.0-beta.4", features = [ "rustls" ] } actix-web = { version = "4.0.0-beta.4", features = [ "rustls" ] }

27
src/cache/fs.rs vendored
View file

@ -106,22 +106,19 @@ async fn read_file(
maybe_header = Some(*XNonce::from_slice(&nonce_bytes)); maybe_header = Some(*XNonce::from_slice(&nonce_bytes));
reader = Some(Box::pin(BufReader::new(EncryptedDiskReader::new( reader = Some(Box::pin(BufReader::new(EncryptedDiskReader::new(
file, file,
XNonce::from_slice(&XNonce::from_slice(&nonce_bytes)), XNonce::from_slice(XNonce::from_slice(&nonce_bytes)),
key, key,
)))); ))));
} }
parsed_metadata = if let Some(reader) = reader.as_mut() { parsed_metadata = if let Some(reader) = reader.as_mut() {
match reader.as_mut().metadata().await { if let Ok(metadata) = reader.as_mut().metadata().await {
Ok(metadata) => {
debug!("Successfully parsed encrypted metadata"); debug!("Successfully parsed encrypted metadata");
Some(metadata) Some(metadata)
} } else {
Err(_) => {
debug!("Failed to parse encrypted metadata"); debug!("Failed to parse encrypted metadata");
None None
} }
}
} else { } else {
debug!("Failed to read encrypted data"); debug!("Failed to read encrypted data");
None None
@ -194,32 +191,26 @@ impl<'a, R: AsyncBufRead> Future for MetadataFuture<'a, R> {
loop { loop {
let buf = match self.0.as_mut().poll_fill_buf(cx) { let buf = match self.0.as_mut().poll_fill_buf(cx) {
Poll::Ready(Ok(buffer)) => buffer, Poll::Ready(Ok(buffer)) => buffer,
Poll::Ready(Err(e)) => { Poll::Ready(Err(_)) => return Poll::Ready(Err(())),
return Poll::Ready(Err(()));
}
Poll::Pending => return Poll::Pending, Poll::Pending => return Poll::Pending,
}; };
if filled == buf.len() { if filled == buf.len() {
return Poll::Ready(Err(())); return Poll::Ready(Err(()));
} else {
filled = buf.len();
} }
filled = buf.len();
let mut reader = serde_json::Deserializer::from_slice(buf).into_iter(); let mut reader = serde_json::Deserializer::from_slice(buf).into_iter();
let (res, bytes_consumed) = match reader.next() { let (res, bytes_consumed) = match reader.next() {
Some(Ok(metadata)) => (Poll::Ready(Ok(metadata)), reader.byte_offset()), Some(Ok(metadata)) => (Poll::Ready(Ok(metadata)), reader.byte_offset()),
Some(Err(e)) if e.is_eof() => { Some(Err(e)) if e.is_eof() => continue,
continue; Some(Err(_)) | None => return Poll::Ready(Err(())),
}
Some(Err(_)) | None => {
return Poll::Ready(Err(()));
}
}; };
// This needs to be outside the loop because we need to drop the // This needs to be outside the loop because we need to drop the
// reader ref, since that depends on a mut self. // reader ref, since that depends on a mut self.
self.0.as_mut().consume(dbg!(bytes_consumed)); self.0.as_mut().consume(bytes_consumed);
return res; return res;
} }
} }

View file

@ -102,9 +102,10 @@ impl Config {
(2, _) => TracingLevelFilter::ERROR, (2, _) => TracingLevelFilter::ERROR,
(1, _) => TracingLevelFilter::WARN, (1, _) => TracingLevelFilter::WARN,
// Use log level from file if no flags were provided to CLI // Use log level from file if no flags were provided to CLI
(0, 0) => file_extended_options (0, 0) => {
file_extended_options
.logging_level .logging_level
.map(|filter| match filter { .map_or(TracingLevelFilter::INFO, |filter| match filter {
LevelFilter::Off => TracingLevelFilter::OFF, LevelFilter::Off => TracingLevelFilter::OFF,
LevelFilter::Error => TracingLevelFilter::ERROR, LevelFilter::Error => TracingLevelFilter::ERROR,
LevelFilter::Warn => TracingLevelFilter::WARN, LevelFilter::Warn => TracingLevelFilter::WARN,
@ -112,7 +113,7 @@ impl Config {
LevelFilter::Debug => TracingLevelFilter::DEBUG, LevelFilter::Debug => TracingLevelFilter::DEBUG,
LevelFilter::Trace => TracingLevelFilter::TRACE, LevelFilter::Trace => TracingLevelFilter::TRACE,
}) })
.unwrap_or(TracingLevelFilter::INFO), }
(_, 1) => TracingLevelFilter::DEBUG, (_, 1) => TracingLevelFilter::DEBUG,
(_, n) if n > 1 => TracingLevelFilter::TRACE, (_, n) if n > 1 => TracingLevelFilter::TRACE,
// compiler can't figure it out // compiler can't figure it out