[fix] debug prints have to go to stderr
This commit is contained in:
parent
7ffd6a4a11
commit
1ae56389fc
@ -35,7 +35,7 @@ pub fn encrypt<S: AsRef<str>>(
|
|||||||
ReadInfo::NormalChunk(n) => {
|
ReadInfo::NormalChunk(n) => {
|
||||||
assert_eq!(n, BUFSIZE);
|
assert_eq!(n, BUFSIZE);
|
||||||
assert_eq!(buf.len(), BUFSIZE);
|
assert_eq!(buf.len(), BUFSIZE);
|
||||||
println!("[encrypt]: read normal chunk");
|
eprintln!("[encrypt]: read normal chunk");
|
||||||
stream_encryptor.encrypt_next_in_place(&[], &mut buf)?;
|
stream_encryptor.encrypt_next_in_place(&[], &mut buf)?;
|
||||||
f_encrypted.write_all(&buf)?;
|
f_encrypted.write_all(&buf)?;
|
||||||
// buf grows after encrypt_next_in_place because of tag that is added
|
// buf grows after encrypt_next_in_place because of tag that is added
|
||||||
@ -43,14 +43,14 @@ pub fn encrypt<S: AsRef<str>>(
|
|||||||
buf.truncate(BUFSIZE);
|
buf.truncate(BUFSIZE);
|
||||||
}
|
}
|
||||||
ReadInfo::LastChunk(n) => {
|
ReadInfo::LastChunk(n) => {
|
||||||
println!("[encrypt]: read last chunk");
|
eprintln!("[encrypt]: read last chunk");
|
||||||
buf.truncate(n);
|
buf.truncate(n);
|
||||||
stream_encryptor.encrypt_last_in_place(&[], &mut buf)?;
|
stream_encryptor.encrypt_last_in_place(&[], &mut buf)?;
|
||||||
f_encrypted.write_all(&buf)?;
|
f_encrypted.write_all(&buf)?;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ReadInfo::EmptyChunk => {
|
ReadInfo::EmptyChunk => {
|
||||||
println!("[encrypt]: read empty chunk");
|
eprintln!("[encrypt]: read empty chunk");
|
||||||
panic!("[ERROR] Empty Chunk while reading");
|
panic!("[ERROR] Empty Chunk while reading");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,20 +81,20 @@ pub fn decrypt<S: AsRef<str>>(
|
|||||||
match read_result {
|
match read_result {
|
||||||
ReadInfo::NormalChunk(n) => {
|
ReadInfo::NormalChunk(n) => {
|
||||||
assert_eq!(n, BUFSIZE + 16);
|
assert_eq!(n, BUFSIZE + 16);
|
||||||
println!("[decrypt]: read normal chunk");
|
eprintln!("[decrypt]: read normal chunk");
|
||||||
stream_decryptor.decrypt_next_in_place(&[], &mut buf)?;
|
stream_decryptor.decrypt_next_in_place(&[], &mut buf)?;
|
||||||
f_plain.write_all(&buf)?;
|
f_plain.write_all(&buf)?;
|
||||||
buf.resize(BUFSIZE + 16, 0);
|
buf.resize(BUFSIZE + 16, 0);
|
||||||
}
|
}
|
||||||
ReadInfo::LastChunk(n) => {
|
ReadInfo::LastChunk(n) => {
|
||||||
println!("[decrypt]: read last chunk");
|
eprintln!("[decrypt]: read last chunk");
|
||||||
buf.truncate(n);
|
buf.truncate(n);
|
||||||
stream_decryptor.decrypt_last_in_place(&[], &mut buf)?;
|
stream_decryptor.decrypt_last_in_place(&[], &mut buf)?;
|
||||||
f_plain.write_all(&buf)?;
|
f_plain.write_all(&buf)?;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ReadInfo::EmptyChunk => {
|
ReadInfo::EmptyChunk => {
|
||||||
println!("[decrypt]: read empty chunk");
|
eprintln!("[decrypt]: read empty chunk");
|
||||||
panic!("Empty Chunk while reading");
|
panic!("Empty Chunk while reading");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,6 @@ fn run(cli: Cli) -> Result<(), FcryError> {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
if let Err(e) = run(cli) {
|
if let Err(e) = run(cli) {
|
||||||
println!("Error: {:?}", e);
|
eprintln!("Error: {:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,11 @@ impl AheadReader {
|
|||||||
pub fn read_ahead(&mut self, userbuf: &mut [u8]) -> io::Result<ReadInfo> {
|
pub fn read_ahead(&mut self, userbuf: &mut [u8]) -> io::Result<ReadInfo> {
|
||||||
// 1st read
|
// 1st read
|
||||||
if self.bufsz == 0 {
|
if self.bufsz == 0 {
|
||||||
println!("[reader] first read");
|
eprintln!("[reader] first read");
|
||||||
return self.first_read(userbuf);
|
return self.first_read(userbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("[reader] normal read");
|
eprintln!("[reader] normal read");
|
||||||
// normal read (not the 1st one)
|
// normal read (not the 1st one)
|
||||||
self.normal_read(userbuf)
|
self.normal_read(userbuf)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user