Skip to content

Commit

Permalink
addressing code review comments from @joehan
Browse files Browse the repository at this point in the history
  • Loading branch information
Durisvk committed Apr 28, 2023
1 parent fc06ab4 commit f5a475f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
- Lift GCF 2nd gen naming restrictions (#5690)
- Fixes a bug where `ext:install` and `ext:configure` would error on extensions with no params.
- Fixed an issue with Vite and Angular integrations using a obsolete NPM command (#5710)
- Fixes bug were emulators would not starting correctly due to corrupted ZIP files. (#5614, #5677)
- Fixes bug where emulators would not start correctly due to corrupted ZIP files. (#5614, #5677)
1 change: 1 addition & 0 deletions scripts/emulator-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./functions/index.js
12 changes: 0 additions & 12 deletions scripts/emulator-tests/functions/index.js

This file was deleted.

8 changes: 6 additions & 2 deletions src/unzip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Readable, Transform, TransformCallback } from "stream";
import { promisify } from "util";
import { FirebaseError } from "./error";
import { pipeline } from "stream";
import { logger } from "./logger";

const pipelineAsync = promisify(pipeline);

Expand Down Expand Up @@ -45,12 +46,15 @@ const extractEntriesFromBuffer = async (data: Buffer, outputDir: string): Promis
position + entry.headerSize,
position + entry.headerSize + entry.compressedSize
);
logger.debug(
`[unzip] Entry: ${entry.fileName} (compressed_size=${entry.compressedSize} bytes, uncompressed_size=${entry.uncompressedSize} bytes)`
);

entry.fileName = entry.fileName.replace(/\//g, path.sep);

const outputFilePath = path.normalize(path.join(outputDir, entry.fileName));

console.log(`Processing entry: \${entry.fileName}`);
logger.debug(`[unzip] Processing entry: ${entry.fileName}`);
if (entry.fileName.endsWith(path.sep)) {
await fs.promises.mkdir(outputFilePath, { recursive: true });
} else {
Expand All @@ -60,7 +64,7 @@ const extractEntriesFromBuffer = async (data: Buffer, outputDir: string): Promis
const compressionMethod = entryHeader.readUInt16LE(8);
if (compressionMethod === 0) {
// Store (no compression)
console.log(`Writing file: \${outputFilePath}`);
logger.debug(`[unzip] Writing file: ${outputFilePath}`);
await fs.promises.writeFile(outputFilePath, entry.compressedData);
} else if (compressionMethod === 8) {
// Deflate
Expand Down

0 comments on commit f5a475f

Please sign in to comment.