Skip to content

Commit

Permalink
Unzip: Only delete a temporary zip file after unzipping, do not delet…
Browse files Browse the repository at this point in the history
…e the original zip (#1412)

Fixes a regression introduced in
#1400 that caused
the original zip file to be deleted.

To test, confirm you can preview
WordPress/wordpress-develop#6318 on this branch.

Closes #1409
  • Loading branch information
adamziel authored May 16, 2024
1 parent 3624eed commit 1b891c2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/playground/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ export const RecommendedPHPVersion = '8.0';
/**
* Unzip a zip file inside Playground.
*/
const tmpPath = '/tmp/file.zip';
export const unzipFile = async (
php: UniversalPHP,
zipPath: string | File,
extractToPath: string
) => {
if (zipPath instanceof File) {
const zipFile = zipPath;
zipPath = '/tmp/file.zip';
zipPath = tmpPath;
await php.writeFile(
zipPath,
new Uint8Array(await zipFile.arrayBuffer())
Expand All @@ -41,8 +42,8 @@ export const unzipFile = async (
php,
`unzip(${js.zipPath}, ${js.extractToPath});`
);
if (php.fileExists(zipPath)) {
await php.unlink(zipPath);
if (php.fileExists(tmpPath)) {
await php.unlink(tmpPath);
}
};

Expand Down

0 comments on commit 1b891c2

Please sign in to comment.