Skip to content

Commit

Permalink
Merge pull request #183 from otoyo/wait-for-stream
Browse files Browse the repository at this point in the history
Use stream/pipeline
  • Loading branch information
otoyo authored Dec 2, 2023
2 parents 0d0bcf9 + 745df32 commit 34eddf8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 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 @@ -410,7 +411,13 @@ export async function downloadFile(url: URL) {
if (res.headers['content-type'] === 'image/jpeg') {
stream = stream.pipe(rotate)
}
return stream.pipe(new ExifTransformer()).pipe(writeStream)
try {
return pipeline(stream, new ExifTransformer(), writeStream)
} catch (err) {
console.log(err)
writeStream.end()
return Promise.resolve()
}
}

export async function getDatabase(): Promise<Database> {
Expand Down

1 comment on commit 34eddf8

@vercel
Copy link

@vercel vercel bot commented on 34eddf8 Dec 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

astro-notion-blog – ./

astro-notion-blog-otoyo.vercel.app
astro-notion-blog-git-main-otoyo.vercel.app
astro-notion-blog-taupe.vercel.app

Please sign in to comment.