Skip to content

Commit 29611ea

Browse files
committed
fix zip
1 parent 9ac287e commit 29611ea

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"files": {
3-
"ignore": ["lib"]
3+
"includes": ["**", "!**/lib"]
44
},
55
"linter": {
66
"enabled": true,

tests/diff.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
22
import fs from 'fs';
3+
import { npm, yarn } from 'global-dirs';
34
import os from 'os';
45
import path from 'path';
5-
import { npm, yarn } from 'global-dirs';
66
import { ZipFile as YazlZipFile } from 'yazl';
77
import { diffCommands, enumZipEntries, readEntry } from '../src/diff';
88
import type { CommandContext } from '../src/types';
9+
import { readEntryPrefix } from '../src/utils/zip-entries';
910

1011
const pngPrefix = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
1112
const hermesBytecodePrefix = Buffer.from([
@@ -292,6 +293,23 @@ describe('diff commands', () => {
292293
expect(result.files['extra/new.txt']?.toString('utf-8')).toBe('new-file');
293294
});
294295

296+
test('readEntryPrefix stops large zip entries without surfacing destroy errors', async () => {
297+
const zipPath = path.join(tempRoot, 'large-entry.ppk');
298+
const payload = Buffer.alloc(256, 'x');
299+
await createZip(zipPath, {
300+
'large-entry.bin': payload,
301+
});
302+
303+
let prefix: Buffer | undefined;
304+
await enumZipEntries(zipPath, async (entry, zipFile) => {
305+
if (entry.fileName === 'large-entry.bin') {
306+
prefix = await readEntryPrefix(entry, zipFile, 64);
307+
}
308+
});
309+
310+
expect(prefix).toEqual(payload.subarray(0, 64));
311+
});
312+
295313
test('diffFromApk throws when origin package bundle is missing', async () => {
296314
const originPath = path.join(tempRoot, 'origin-missing-bundle.apk');
297315
const nextPath = path.join(tempRoot, 'next-for-apk.ppk');

0 commit comments

Comments
 (0)