Skip to content

Corrupted unzipped files when using Extract #286

Closed
@marcogrcr

Description

@marcogrcr

I'm trying to unzip a .zip file containing chromedriver using [email protected]. When attempting to unzip chromedriver_linux64.zip downloaded from here, the extraction succeeds, but the executable is corrupted:

$ unzip chromedriver_linux64.zip

$ md5sum chromedriver
ee3dba5202ae87d7b79c22341030db49

$ ./chromedriver
Starting ChromeDriver 111.0.5563.64 (c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
import { createReadStream } from "node:fs";
import { Extract } from "unzipper";

await createReadStream("chromedriver_linux64.zip")
      .pipe(Extract({ path: "/tmp" }))
      .promise();

Then, when I run:

$ md5sum /tmp/chromedriver
641c5ede222e09e76fe52bc1bc61c0a9

$ /tmp/chromedriver
zsh: permission denied: /tmp/chromedriver

$ chmod +x /tmp/chromedriver

$ /tmp/chromedriver
zsh: exec format error: /tmp/chromedriver

Since I wasn't sure if I was using the .promise() method correctly, I also tried using the equivalent of the README example, but got the same results:

import { createReadStream } from "node:fs";
import { Extract } from "unzipper";

await new Promise((resolve, reject) => {
  createReadStream(driverPkg)
    .pipe(Extract({ path: destinationFolder }))
    .on("close", () => resolve(void 0))
    .on("error", e => reject(e));
});

However, this works just fine with [email protected]:

import extractZip from "extract-zip";

await extractZip("chromedriver_linux64.zip", { dir: "/tmp" })

Then, when I run:

$ md5sum chromedriver
ee3dba5202ae87d7b79c22341030db49

$ /tmp/chromedriver
Starting ChromeDriver 111.0.5563.64 (c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions