diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-07-07 10:53:06 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-07-07 10:53:06 +0900 |
| commit | d5c4e77c44a0d72670e3679294219329898c8e00 (patch) | |
| tree | 2c1b3b6331b6daee765569f8d248323fc3cc2a58 /packages/backend/src/core/FileInfoService.ts | |
| parent | Update .gitignore (diff) | |
| download | sharkey-d5c4e77c44a0d72670e3679294219329898c8e00.tar.gz sharkey-d5c4e77c44a0d72670e3679294219329898c8e00.tar.bz2 sharkey-d5c4e77c44a0d72670e3679294219329898c8e00.zip | |
update deps
Diffstat (limited to 'packages/backend/src/core/FileInfoService.ts')
| -rw-r--r-- | packages/backend/src/core/FileInfoService.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/packages/backend/src/core/FileInfoService.ts b/packages/backend/src/core/FileInfoService.ts index b6cae5ea75..d6c51ad559 100644 --- a/packages/backend/src/core/FileInfoService.ts +++ b/packages/backend/src/core/FileInfoService.ts @@ -304,11 +304,11 @@ export class FileInfoService { @bindThis public fixMime(mime: string | fileType.MimeType): string { // see https://github.com/misskey-dev/misskey/pull/10686 - if (mime === "audio/x-flac") { - return "audio/flac"; + if (mime === 'audio/x-flac') { + return 'audio/flac'; } - if (mime === "audio/vnd.wave") { - return "audio/wav"; + if (mime === 'audio/vnd.wave') { + return 'audio/wav'; } return mime; @@ -355,11 +355,12 @@ export class FileInfoService { * Check the file is SVG or not */ @bindThis - public async checkSvg(path: string) { + public async checkSvg(path: string): Promise<boolean> { try { const size = await this.getFileSize(path); if (size > 1 * 1024 * 1024) return false; - return isSvg(fs.readFileSync(path)); + const buffer = await fs.promises.readFile(path); + return isSvg(buffer.toString()); } catch { return false; } |