More debugging
This commit is contained in:
parent
6ac8582183
commit
94375b185f
3 changed files with 28 additions and 36 deletions
|
@ -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" ] }
|
||||||
|
|
35
src/cache/fs.rs
vendored
35
src/cache/fs.rs
vendored
|
@ -106,21 +106,18 @@ 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 {
|
||||||
}
|
debug!("Failed to parse encrypted metadata");
|
||||||
Err(_) => {
|
None
|
||||||
debug!("Failed to parse encrypted metadata");
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug!("Failed to read encrypted data");
|
debug!("Failed to read encrypted data");
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,17 +102,18 @@ 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) => {
|
||||||
.logging_level
|
file_extended_options
|
||||||
.map(|filter| match filter {
|
.logging_level
|
||||||
LevelFilter::Off => TracingLevelFilter::OFF,
|
.map_or(TracingLevelFilter::INFO, |filter| match filter {
|
||||||
LevelFilter::Error => TracingLevelFilter::ERROR,
|
LevelFilter::Off => TracingLevelFilter::OFF,
|
||||||
LevelFilter::Warn => TracingLevelFilter::WARN,
|
LevelFilter::Error => TracingLevelFilter::ERROR,
|
||||||
LevelFilter::Info => TracingLevelFilter::INFO,
|
LevelFilter::Warn => TracingLevelFilter::WARN,
|
||||||
LevelFilter::Debug => TracingLevelFilter::DEBUG,
|
LevelFilter::Info => TracingLevelFilter::INFO,
|
||||||
LevelFilter::Trace => TracingLevelFilter::TRACE,
|
LevelFilter::Debug => TracingLevelFilter::DEBUG,
|
||||||
})
|
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
|
||||||
|
|
Loading…
Reference in a new issue