dyz1990 / sevenz-rust

A 7z decompressor/compressor lib written in pure rust
Apache License 2.0
146 stars 24 forks source link

Bug: Unable to decompress due to bad signature error. #33

Closed rawhuul closed 11 months ago

rawhuul commented 11 months ago

Hi there, I was trying to decompress vscode archive, using this library it fails due to bad signature error, however through cli, I'm able to decompresses it successfully, below are screenshots for same.

Using Rust code:

pub fn install(app: &str) {
    let query = app.trim().to_lowercase();

    let (app_name, manifest) = match query.split_once('/') {
        Some((bucket, app_name)) => (
            app_name,
            Buckets::query_app(app_name)
                .unwrap()
                .get_app_from(app_name, bucket),
        ),
        None => (app, Buckets::query_app(app).unwrap().get_app(app)),
    };

    let manifest = manifest.unwrap();
    let file_name = Downloader::download(app_name, true).unwrap();
    let cache_dir = Config::cache_dir().unwrap();

    let srcs = file_name
        .iter()
        .map(|f| match f {
            DownloadStatus::Downloaded(s) => s,
            DownloadStatus::DownloadedAndVerified(s) => s,
            DownloadStatus::AlreadyInCache(s) => s,
        })
        .map(|s| cache_dir.join(s))
        .collect::<Vec<_>>();

    let version = &manifest.version;

    let app_dir = Config::app_dir().unwrap();
    let app_dir = app_dir.join(app_name);
    let app_dir = app_dir.join(version);

    if !app_dir.exists() {
        PathBuf::create(app_dir.clone()).unwrap();
        use sevenz_rust::decompress_file;
        for src in srcs {
            if src
                .extension()
                .unwrap_or_default()
                .to_string_lossy()
                .to_string()
                == "7z"
            {
                println!("decompressingn {:?}", src);
                decompress_file(src, &app_dir).unwrap();
            }
        }
    }

    // println!("{app_name}\n{manifest:#?}\n{file_name:#?} at {app_dir:?}");
}

I gets: image

However using 7z cli: image

dyz1990 commented 11 months ago

it is not a '7z' archive, but a 'zip' archive. you can see the warning of the 7z cli.

rawhuul commented 11 months ago

it is not a '7z' archive, but a 'zip' archive. you can see the warning of the 7z cli.

Isn't it supposed to handle zip file as well, as 7z does?

dyz1990 commented 11 months ago

it is not a '7z' archive, but a 'zip' archive. you can see the warning of the 7z cli.

Isn't it supposed to handle zip file as well, as 7z does?

No, This library is not like the 7z cli program, it is only used to compress and decompress files in 7z format. And there are certain features in 7z this lib doesn't support,

rawhuul commented 11 months ago

Okay thanks!!