forked from mirror/misskey
clean up
This commit is contained in:
parent
453ba25af2
commit
038d71988f
@ -333,7 +333,7 @@ export class FileInfoService {
|
|||||||
// 種類が不明でもSVGかもしれない
|
// 種類が不明でもSVGかもしれない
|
||||||
if (await this.checkSvg(path)) {
|
if (await this.checkSvg(path)) {
|
||||||
return TYPE_SVG;
|
return TYPE_SVG;
|
||||||
}
|
}
|
||||||
|
|
||||||
// それでも種類が不明なら application/octet-stream にする
|
// それでも種類が不明なら application/octet-stream にする
|
||||||
return TYPE_OCTET_STREAM;
|
return TYPE_OCTET_STREAM;
|
||||||
@ -371,16 +371,11 @@ export class FileInfoService {
|
|||||||
* Check the file is SVG or not
|
* Check the file is SVG or not
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async checkSvg(target: string | Buffer) {
|
public async checkSvg(path: string) {
|
||||||
try {
|
try {
|
||||||
if (typeof target === 'string') {
|
const size = await this.getFileSize(path);
|
||||||
const size = await this.getFileSize(target);
|
if (size > 1 * 1024 * 1024) return false;
|
||||||
if (size > 1 * 1024 * 1024) return false;
|
return isSvg(await fs.promises.readFile(target));
|
||||||
return isSvg(await fs.promises.readFile(target));
|
|
||||||
} else {
|
|
||||||
if (target.length > 1 * 1024 * 1024) return false;
|
|
||||||
return isSvg(target);
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user