From 8aafafe416f6a511a60728ec8859ab0a9df711ad Mon Sep 17 00:00:00 2001 From: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com> Date: Tue, 7 Jan 2020 23:34:17 +0900 Subject: [PATCH] Fix #5688 (#5689) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Resolve #5688 * あああああ * :innocent: * :thinking_face: * Update detect-mine.ts Co-authored-by: syuilo --- src/misc/detect-mine.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/misc/detect-mine.ts b/src/misc/detect-mine.ts index b22873369..f47f12735 100644 --- a/src/misc/detect-mine.ts +++ b/src/misc/detect-mine.ts @@ -1,15 +1,15 @@ import * as fs from 'fs'; -import fileType = require('file-type'); import checkSvg from '../misc/check-svg'; +const FileType = require('file-type'); export async function detectMine(path: string) { return new Promise<[string, string | null]>((res, rej) => { const readable = fs.createReadStream(path); readable .on('error', rej) - .once('data', (buffer: Buffer) => { + .once('data', async (buffer: Buffer) => { readable.destroy(); - const type = fileType(buffer); + const type = await FileType.fromBuffer(buffer); if (type) { if (type.mime == 'application/xml' && checkSvg(path)) { res(['image/svg+xml', 'svg']);