Skip to content

Commit

Permalink
Use pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
otoyo committed Dec 2, 2023
1 parent 4824f96 commit ad848aa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/notion/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs, { createWriteStream } from 'node:fs'
import { pipeline } from 'node:stream/promises'
import axios, { AxiosResponse } from 'axios'
import sharp from 'sharp'
import retry from 'async-retry'
Expand Down Expand Up @@ -419,7 +420,11 @@ export async function downloadFile(url: URL) {
stream = stream.pipe(rotate)
}
try {
stream.pipe(new ExifTransformer()).pipe(writeStream)
await pipeline(
stream,
new ExifTransformer(),
writeStream,
)
} catch (err) {
console.log(err)
writeStream.end()
Expand Down

0 comments on commit ad848aa

Please sign in to comment.