support reading log.gz files

This commit is contained in:
Robin Appelman 2024-08-08 13:45:50 +02:00
commit 4737a0db3c
4 changed files with 13 additions and 3 deletions

View file

@ -1,4 +1,5 @@
use crate::error::ReadError;
use flate2::read::GzDecoder;
use std::fs::File;
use std::io::Read;
use zip::ZipArchive;
@ -22,6 +23,12 @@ impl LogFile {
let mut content = String::with_capacity(log.size() as usize);
log.read_to_string(&mut content)?;
Ok(LogFile { content })
} else if path.ends_with(".gz") {
let mut decoder = GzDecoder::new(file);
let mut content = String::new();
decoder.read_to_string(&mut content)?;
Ok(LogFile { content })
} else {
let mut content = String::new();