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

fix: do not create read stream for zip entries that are not being extracted #13792

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Comment on lines +117 to +119
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we log what symlink is that?

}
const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
await pipeline(readStream, createWriteStream(dest, { mode: procMode }));
}

getExtractedMode(entryMode, isDir) {
Expand Down
Loading