Seek file from beginning on encrypted header

This commit is contained in:
Edward Shen 2021-07-11 13:25:02 -04:00
parent 5143dff888
commit 92a66e60dc
Signed by: edward
GPG key ID: 19182661E818369F

3
src/cache/fs.rs vendored
View file

@ -30,7 +30,7 @@ use sodiumoxide::crypto::secretstream::{
Header, Pull, Push, Stream as SecretStream, Tag, HEADERBYTES, Header, Pull, Push, Stream as SecretStream, Tag, HEADERBYTES,
}; };
use tokio::fs::{create_dir_all, remove_file, File}; use tokio::fs::{create_dir_all, remove_file, File};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncSeekExt, AsyncWrite, AsyncWriteExt, ReadBuf};
use tokio::sync::mpsc::Sender; use tokio::sync::mpsc::Sender;
use tokio_util::codec::{BytesCodec, FramedRead}; use tokio_util::codec::{BytesCodec, FramedRead};
@ -88,6 +88,7 @@ async fn read_file(
debug!("Found not encrypted file"); debug!("Found not encrypted file");
} else { } else {
let mut file = File::from_std(file_1); let mut file = File::from_std(file_1);
file.seek(SeekFrom::Start(0)).await.ok()?;
let file_0 = file.try_clone().await.unwrap(); let file_0 = file.try_clone().await.unwrap();
// image is encrypted or corrupt // image is encrypted or corrupt