Skip to content

Commit

Permalink
fix: do not create read stream for zip entries that are not being ext…
Browse files Browse the repository at this point in the history
…racted
  • Loading branch information
Amplifiyer committed May 23, 2024
1 parent 08f358d commit 883b23b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/amplify-cli-core/src/extractZip.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const path = require('path');
const { promisify } = require('util');
const stream = require('stream');
const yauzl = require('yauzl');
const { getAmplifyLogger } = require('@aws-amplify/amplify-cli-logger');

const openZip = promisify(yauzl.open);
const pipeline = promisify(stream.pipeline);
Expand Down Expand Up @@ -113,11 +114,12 @@ class Extractor {
await fs.mkdir(destDir, mkdirOptions);
if (isDir) return;

const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);

if (!symlink) {
await pipeline(readStream, createWriteStream(dest, { mode: procMode }));
if (symlink) {
getAmplifyLogger().logError({ message: 'Found symlinks in the zipped directory. These symlinks will not be extracted' });
return;
}
const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
await pipeline(readStream, createWriteStream(dest, { mode: procMode }));
}

getExtractedMode(entryMode, isDir) {
Expand Down

0 comments on commit 883b23b

Please sign in to comment.