Skip to content

Commit b79a522

Browse files
committed
use chunkd/fs lib
1 parent 00dd907 commit b79a522

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/storage.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { fsa } from '@chunkd/fs';
55
import { HashTransform } from '@chunkd/fs/build/src/hash.stream.js';
66
import { FsAwsS3 } from '@chunkd/fs-aws';
77
import type { LambdaRequest, LogType } from '@linzjs/lambda';
8-
import { createWriteStream, rmSync } from 'fs';
8+
import { rmSync } from 'fs';
99
import { Readable } from 'stream';
10-
import { pipeline } from 'stream/promises';
1110
import type { Entry } from 'yauzl';
1211
import yauzl from 'yauzl';
1312

@@ -58,16 +57,16 @@ export async function extractAndWritePackage(
5857
datasetId: number,
5958
log: LogType,
6059
): Promise<void> {
61-
const tmpZipFile = `/tmp/${datasetId}.zip`;
60+
const tmpZipFile = new URL(`${datasetId}.zip`, '/tmp');
6261
try {
63-
await pipeline(stream, createWriteStream(tmpZipFile));
62+
await fsa.write(tmpZipFile, stream);
6463
const fileNames: string[] = [];
6564

6665
const writeProms: Promise<void>[] = [];
6766

6867
return new Promise((resolve, reject) => {
69-
yauzl.open(tmpZipFile, { lazyEntries: true }, (err, zipFile) => {
70-
if (err) reject(`Failed to open zip file ${tmpZipFile}`);
68+
yauzl.open(tmpZipFile.pathname, { lazyEntries: true }, (err, zipFile) => {
69+
if (err) reject(`Failed to open zip file ${tmpZipFile.pathname}`);
7170

7271
zipFile.once('end', () => {
7372
Promise.all(writeProms)

0 commit comments

Comments
 (0)