mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 18:14:11 +02:00
rar fixes
This commit is contained in:
parent
1b128bf177
commit
cd36ba9a8f
7 changed files with 51 additions and 25 deletions
|
|
@ -27,12 +27,19 @@ pub enum ReadError {
|
|||
Zstd(#[from] FrameDecoderError),
|
||||
#[error(transparent)]
|
||||
SevenZip(#[from] sevenz_rust2::Error),
|
||||
#[cfg(all(unix, not(target_env = "musl")))]
|
||||
#[error(transparent)]
|
||||
Rar(#[from] unrar::error::UnrarError),
|
||||
#[error("archive contains no files")]
|
||||
NoFiles,
|
||||
#[error("log file contained non-utf8 characters: {0:#}")]
|
||||
Utf8(#[from] FromUtf8Error),
|
||||
#[allow(dead_code)]
|
||||
#[error("Opening {format} is not supported{details}")]
|
||||
UnSupportedFormat {
|
||||
format: &'static str,
|
||||
details: &'static str,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#[cfg(all(unix, not(target_env = "musl")))]
|
||||
mod rar;
|
||||
mod sevenzip;
|
||||
mod tar;
|
||||
|
|
@ -7,6 +8,7 @@ use crate::error::ReadError;
|
|||
use std::borrow::Cow;
|
||||
use std::io::Read;
|
||||
|
||||
#[cfg(all(unix, not(target_env = "musl")))]
|
||||
pub use rar::RarArchive;
|
||||
pub use sevenzip::SevenZipArchive;
|
||||
pub use tar::TarArchive;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ impl Archive for RarArchive {
|
|||
.open_for_listing()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|header| RarEntry {
|
||||
archive: self.path.clone(),
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ mod archive;
|
|||
pub mod logline;
|
||||
|
||||
use crate::error::ReadError;
|
||||
use crate::logfile::archive::{
|
||||
Archive, ArchiveEntry, RarArchive, SevenZipArchive, TarArchive, ZipArchive,
|
||||
};
|
||||
#[cfg(all(unix, not(target_env = "musl")))]
|
||||
use crate::logfile::archive::RarArchive;
|
||||
use crate::logfile::archive::{Archive, ArchiveEntry, SevenZipArchive, TarArchive, ZipArchive};
|
||||
use bzip2_rs::DecoderReader;
|
||||
use csv::Reader;
|
||||
use dialoguer::Select;
|
||||
|
|
@ -43,8 +43,21 @@ impl LogFile {
|
|||
let mut zip = SevenZipArchive::new(file)?;
|
||||
return select_file(&mut zip);
|
||||
} else if path.ends_with(".rar") {
|
||||
let mut rar = RarArchive::new(path)?;
|
||||
return select_file(&mut rar);
|
||||
#[cfg(all(unix, not(target_env = "musl")))]
|
||||
{
|
||||
let mut rar = RarArchive::new(path)?;
|
||||
return select_file(&mut rar);
|
||||
}
|
||||
#[cfg(target_env = "musl")]
|
||||
return Err(ReadError::UnSupportedFormat {
|
||||
format: "raw",
|
||||
details: " on static builds",
|
||||
});
|
||||
#[cfg(not(unix))]
|
||||
return Err(ReadError::UnSupportedFormat {
|
||||
format: "raw",
|
||||
details: " on windows",
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(path) = path.strip_suffix(".gz") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue