From 92a66e60dc79d20d2692f87bb149d3468d5d4851 Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Sun, 11 Jul 2021 13:25:02 -0400 Subject: [PATCH] Seek file from beginning on encrypted header --- src/cache/fs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cache/fs.rs b/src/cache/fs.rs index 5d62e3f..61c43f0 100644 --- a/src/cache/fs.rs +++ b/src/cache/fs.rs @@ -30,7 +30,7 @@ use sodiumoxide::crypto::secretstream::{ Header, Pull, Push, Stream as SecretStream, Tag, HEADERBYTES, }; 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_util::codec::{BytesCodec, FramedRead}; @@ -88,6 +88,7 @@ async fn read_file( debug!("Found not encrypted file"); } else { let mut file = File::from_std(file_1); + file.seek(SeekFrom::Start(0)).await.ok()?; let file_0 = file.try_clone().await.unwrap(); // image is encrypted or corrupt