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
|
|
@ -29,7 +29,6 @@ xz2 = "0.1.7"
|
|||
bzip2-rs = "0.1.2"
|
||||
ruzstd = "0.8.0"
|
||||
sevenz-rust2 = "0.13.2"
|
||||
unrar = "0.5.8"
|
||||
dialoguer = "0.11.0"
|
||||
indicatif = { version = "0.17.11", features = ["rayon"] }
|
||||
csv = "1.3.1"
|
||||
|
|
@ -37,6 +36,9 @@ csv = "1.3.1"
|
|||
[target.'cfg(target_env = "musl")'.dependencies]
|
||||
tikv-jemallocator = "0.6.0"
|
||||
|
||||
[target.'cfg(all(unix, not(target_env = "musl")))'.dependencies]
|
||||
unrar = "0.5.8"
|
||||
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
|
||||
|
|
|
|||
34
flake.lock
generated
34
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1742394900,
|
||||
"narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=",
|
||||
"lastModified": 1748970125,
|
||||
"narHash": "sha256-UDyigbDGv8fvs9aS95yzFfOKkEjx1LO3PL3DsKopohA=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd",
|
||||
"rev": "323b5746d89e04b22554b061522dfce9e4c49b18",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -22,11 +22,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1748263617,
|
||||
"narHash": "sha256-O1xypYFWzYlfiyO3fUZuzRhYac5DGptP+ZhocY9L5tQ=",
|
||||
"lastModified": 1751287849,
|
||||
"narHash": "sha256-tpOX5x+Chodk/v8wYIzncX5Sq7mbKe0mMAWN0leYpCI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flakelight",
|
||||
"rev": "65c783ba2b85910df5a053cb1451e9eb13794c12",
|
||||
"rev": "16a2ab5cdc789682d80c2c8511df338fd13fc1ca",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -44,11 +44,11 @@
|
|||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1748205441,
|
||||
"narHash": "sha256-W+UUBT/l1DSTZo5G43494mRNNspJ2i9jW2QELC9JuMQ=",
|
||||
"lastModified": 1751383294,
|
||||
"narHash": "sha256-Yg24QBWnVojoD7jVH47BFYkMmjWaZKeJNMqCI75bYLo=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "dac3b74a89cebbeb21cc6602e4a346604adbee8b",
|
||||
"revCount": 49,
|
||||
"rev": "114f11c2a3af921dc5ef459ce7f2636dfab7171e",
|
||||
"revCount": 55,
|
||||
"type": "git",
|
||||
"url": "https://codeberg.org/icewind/mill-scale.git"
|
||||
},
|
||||
|
|
@ -59,16 +59,16 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1748037224,
|
||||
"narHash": "sha256-92vihpZr6dwEMV6g98M5kHZIttrWahb9iRPBm1atcPk=",
|
||||
"lastModified": 1751211869,
|
||||
"narHash": "sha256-1Cu92i1KSPbhPCKxoiVG5qnoRiKTgR5CcGSRyLpOd7Y=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f09dede81861f3a83f7f06641ead34f02f37597f",
|
||||
"rev": "b43c397f6c213918d6cfe6e3550abfe79b5d1c51",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-24.11",
|
||||
"ref": "nixos-25.05",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
|
|
@ -88,11 +88,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1742697269,
|
||||
"narHash": "sha256-Lpp0XyAtIl1oGJzNmTiTGLhTkcUjwSkEb0gOiNzYFGM=",
|
||||
"lastModified": 1750214276,
|
||||
"narHash": "sha256-1kniuhH70q4TAC/xIvjFYH46aHiLrbIlcr6fdrRwO1A=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "01973c84732f9275c50c5f075dd1f54cc04b3316",
|
||||
"rev": "f9b2b2b1327ff6beab4662b8ea41689e0a57b8d4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-24.11";
|
||||
nixpkgs.url = "nixpkgs/nixos-25.05";
|
||||
flakelight = {
|
||||
url = "github:nix-community/flakelight";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
|
@ -12,6 +12,9 @@
|
|||
};
|
||||
outputs = {mill-scale, ...}:
|
||||
mill-scale ./. {
|
||||
nixpkgs.config = {
|
||||
allowUnfreePredicate = pkg: pkg .pname == "unrar";
|
||||
};
|
||||
crossTargets = [
|
||||
"x86_64-unknown-linux-musl"
|
||||
"x86_64-pc-windows-gnu"
|
||||
|
|
|
|||
|
|
@ -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,9 +43,22 @@ impl LogFile {
|
|||
let mut zip = SevenZipArchive::new(file)?;
|
||||
return select_file(&mut zip);
|
||||
} else if path.ends_with(".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") {
|
||||
let decoder = GzDecoder::new(file);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue