Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting all files extracted #278

Closed
millerds opened this issue May 11, 2023 · 13 comments
Closed

Not getting all files extracted #278

millerds opened this issue May 11, 2023 · 13 comments

Comments

@millerds
Copy link

I have a yeoman generator plugin that uses unzipper to extract the contents of a zip file downloaded from github (https://github.com/OfficeDev/office-addin-taskpane/archive/yo-office.zip) as the basis of a new project (see code snippet below). However, after the new version of unzipper was published then the extraction wasn't getting all the files from the zip file, but it wasn't reporting any errors.

        readStream.pipe(unzip.Extract({ path: projectFolder }))
            .on('error', function (err) {
                reject(``Unable to unzip project zip file for "${projectFolder}".\n${err}``);
            })
            .on('close', async () => {
                moveProjectFiles(projectFolder);
                resolve();
            });
@MasterDover
Copy link

can confirm this is happening to me to on v0.10.14 I have a 'root' zip that contains 36 HTML files, only the first 29 are actually being extracted (no errors).

I resolved by downgrading my version to 0.10.0

@ColeMurray
Copy link

Confirming similar behavior after updating from 0.10.5 to 0.10.14

@ColeMurray
Copy link

Potentially related: #271

@jasondalycan
Copy link

Same issue. Downgraded to 0.10.11 to resolve.

@mayankk96
Copy link

Neither 0.10.0 nor 0.10.11 worked.

@bpavlov
Copy link

bpavlov commented Sep 5, 2023

Same issue. Downgraded to 0.10.11 to resolve.

@millerds
Copy link
Author

Any progress on this issue?

@mjones129
Copy link

Just chiming in to confirm as well. I'm unzipping a WordPress plugin, and I'm consistently not getting the plugin header file, which shares the same name as the .zip being extracted as well as the only and primary subdirectory. So for example, when extracting woocommerce.zip, expected output is a folder named woocommerce and a woocommerce.php file inside. It appears that everything was extracted, but woocommerce.php is missing.

async function decompressFile(file) {
  console.log('Extracting...');
  fs.createReadStream(file)
  .pipe(unzipper.Extract({ path: outputDirectory })).on('close', function(err) {
    if (err) throw err;
    console.log('Extraction complete.');
  })
    return;
}

This is with Unzipper version 0.10.14

@tommoor
Copy link

tommoor commented Nov 12, 2023

@ZJONSSON I would be interested in helping fix whatever regressed between 0.10.11 and 0.10.14 however none of the newer tags have been published to the repo, there's also nothing in GitHub releases.

Are you able to publish the tags so someone can at least try to fix this issue? Alternatively it might be wise to mark the repo as unmaintained as the functionality is broken in such a way that it could cause some really sticky problems.

@philipgriffin
Copy link

philipgriffin commented Nov 29, 2023

I also unfortunately have this issue, while downgrading solved it initially I began to have other problems. I have decided to switch to using tar files instead, just leaving as a suggestion for others if they aren't set on zip.

I used https://www.npmjs.com/package/tar

Here is my sample code:

import fs from "fs/promises";
import tar from "tar";
import path from "path";

// Create tar file
async function createTar(FolderToTar: string, outputTarPath: string): Promise<void> {
  console.log(`Creating tar file at ${outputTarPath}`);

  try {
    await tar.create(
      {
        gzip: false,
        file: outputTarPath,
        cwd: FolderToTar
      },
      ["."]
    );

    console.log("Tar creation completed successfully.");
  } catch (error) {
    console.error(`Error creating tar file: ${error}`);
    throw error;
  }
}

// Extract tar file
async function extract(directory: string): Promise<void> {
  try {
    await fs.mkdir(directory, { recursive: true });

    const tarFilePath = path.join(__dirname, "bp.tar.gz");

    await tar.extract({
      file: tarFilePath,
      cwd: directory
    });

    console.log("Extraction completed successfully.");
  } catch (error) {
    console.error(`Error extracting data: ${error}`);
    throw error;
  }
}

@HanzCEO
Copy link

HanzCEO commented Apr 29, 2024

This is till happening in 0.11.4, is there any alternative package to use?

@mjones129
Copy link

This is till happening in 0.11.4, is there any alternative package to use?

@HanzCEO I ended up using extract-zip and haven't had any issues with it. https://www.npmjs.com/package/extract-zip

@ZJONSSON
Copy link
Owner

ZJONSSON commented Jun 8, 2024

The extract method in latest release v0.12.1 now use fs-extra instead of fstream.

Please also note that certain node versions had a bug related to createWriteStream , fixed in the following versions:
v18.20.0
v20.12.0
v21.7.1

(see here for more detail)

Please reopen or submit new issue if extract continues to cause problems

@ZJONSSON ZJONSSON closed this as completed Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests