Skip to content

Commit ebb56a5

Browse files
authored
Follow symlinks in Preview sites when archiving directories (#1447)
* Follow symlinks in Preview sites when archiving directories * Add release note * Use an option in the archiver instead of harcoding the value * Fix error in type declaration * Add new option to tests
1 parent 2e2f450 commit ebb56a5

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Unreleased
22
==========
33
* Miscellaneous security improvements #1411
4+
* Follow symlinks when creating preview sites #1447
45

56
1.5.2
67
=====

cli/lib/archive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export async function createArchive(
1414
const output = fs.createWriteStream( archivePath );
1515
const archive = archiver( 'zip', {
1616
zlib: { level: ZIP_COMPRESSION_LEVEL },
17+
followSymlinks: true,
1718
} );
1819

1920
output.on( 'close', () => {

cli/lib/tests/archive.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ describe( 'Archive Module', () => {
4848
const result = await createArchive( mockSiteFolder, mockArchivePath );
4949

5050
expect( fs.createWriteStream ).toHaveBeenCalledWith( mockArchivePath );
51-
expect( archiver ).toHaveBeenCalledWith( 'zip', { zlib: { level: 9 } } );
51+
expect( archiver ).toHaveBeenCalledWith( 'zip', {
52+
followSymlinks: true,
53+
zlib: { level: 9 },
54+
} );
5255
expect( mockArchiver.pipe ).toHaveBeenCalledWith( mockWriteStream );
5356
expect( path.join ).toHaveBeenCalledWith( mockSiteFolder, 'wp-content' );
5457
expect( mockArchiver.directory ).toHaveBeenCalledWith(
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/node_modules/@types/archiver/index.d.ts b/node_modules/@types/archiver/index.d.ts
2+
index 00829ac..fab29c9 100644
3+
--- a/node_modules/@types/archiver/index.d.ts
4+
+++ b/node_modules/@types/archiver/index.d.ts
5+
@@ -106,6 +106,7 @@ declare namespace archiver {
6+
7+
interface CoreOptions {
8+
statConcurrency?: number | undefined;
9+
+ followSymlinks?: boolean
10+
}
11+
12+
interface TransformOptions {

patches/archiver+6.0.1.patch

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/node_modules/archiver/lib/core.js b/node_modules/archiver/lib/core.js
2+
index 7c0a74d..c70117b 100644
3+
--- a/node_modules/archiver/lib/core.js
4+
+++ b/node_modules/archiver/lib/core.js
5+
@@ -631,7 +631,8 @@ Archiver.prototype.directory = function(dirpath, destpath, data) {
6+
7+
var globOptions = {
8+
stat: true,
9+
- dot: true
10+
+ dot: true,
11+
+ follow: this.options.followSymlinks
12+
};
13+
14+
function onGlobEnd() {
15+
@@ -922,6 +923,7 @@ module.exports = Archiver;
16+
* @global
17+
* @property {Number} [statConcurrency=4] Sets the number of workers used to
18+
* process the internal fs stat queue.
19+
+ * @property {Boolean} [followSymLinks=false] Sets whether to follow symlinks.
20+
*/
21+
22+
/**

0 commit comments

Comments
 (0)