mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
More debugging because apparently checksums are the bane of my existence. But it works and I was just an idiot
This commit is contained in:
@ -10,23 +10,28 @@ use urlencoding::encode;
|
|||||||
|
|
||||||
pub struct FileWriter {
|
pub struct FileWriter {
|
||||||
file: File,
|
file: File,
|
||||||
hasher: Context
|
hasher: Context,
|
||||||
|
data: Vec<u8>
|
||||||
}
|
}
|
||||||
impl FileWriter {
|
impl FileWriter {
|
||||||
fn new(path: PathBuf) -> Self {
|
fn new(path: PathBuf) -> Self {
|
||||||
Self {
|
Self {
|
||||||
file: OpenOptions::new().write(true).open(path).unwrap(),
|
file: OpenOptions::new().write(true).open(path).unwrap(),
|
||||||
hasher: Context::new()
|
hasher: Context::new(),
|
||||||
|
data: Vec::new()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn finish(mut self) -> Digest {
|
fn finish(mut self) -> Digest {
|
||||||
self.flush();
|
self.flush();
|
||||||
self.hasher.compute()
|
let res = self.hasher.compute();
|
||||||
|
info!("Final calculated value hash: {:?}", hex::encode(res.0));
|
||||||
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Write for FileWriter {
|
impl Write for FileWriter {
|
||||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||||
self.hasher.write(buf);
|
self.hasher.write(buf);
|
||||||
|
self.data.extend_from_slice(buf);
|
||||||
self.file.write(buf)
|
self.file.write(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user