Skip to content

Commit bf639d0

Browse files
authored
Merge pull request #13792 from aws-amplify/extractZipFix3
fix: do not create read stream for zip entries that are not being extracted
2 parents 08f358d + 883b23b commit bf639d0

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/amplify-cli-core/src/extractZip.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const path = require('path');
99
const { promisify } = require('util');
1010
const stream = require('stream');
1111
const yauzl = require('yauzl');
12+
const { getAmplifyLogger } = require('@aws-amplify/amplify-cli-logger');
1213

1314
const openZip = promisify(yauzl.open);
1415
const pipeline = promisify(stream.pipeline);
@@ -113,11 +114,12 @@ class Extractor {
113114
await fs.mkdir(destDir, mkdirOptions);
114115
if (isDir) return;
115116

116-
const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
117-
118-
if (!symlink) {
119-
await pipeline(readStream, createWriteStream(dest, { mode: procMode }));
117+
if (symlink) {
118+
getAmplifyLogger().logError({ message: 'Found symlinks in the zipped directory. These symlinks will not be extracted' });
119+
return;
120120
}
121+
const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
122+
await pipeline(readStream, createWriteStream(dest, { mode: procMode }));
121123
}
122124

123125
getExtractedMode(entryMode, isDir) {

0 commit comments

Comments
 (0)