From f6a7490214a3dfe4713cdec13853d97736c3f641 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Sun, 18 Jul 2021 16:06:49 -0400 Subject: [PATCH] Skip empty or invalid file archives --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1d89b78..c8d191c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -254,7 +254,13 @@ pub async fn main() -> Result<()> { let mut initial_bytes = [0; 8]; tokio_file.seek(SeekFrom::Start(0)).await?; - tokio_file.read_exact(&mut initial_bytes).await?; + match tokio_file.read_exact(&mut initial_bytes).await { + Err(err) => { + warn!(error = %err, "failed to read initial bytes, skipping file"); + continue; + } + _ => {} + } let kind = infer::get(&initial_bytes).expect("unknown file type of file download"); info!( mime_type = kind.mime_type(),