From 72754ede4ed05c71c2777ac5fc021f3b1485be7f Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 21 Oct 2018 18:35:36 +0900 Subject: [PATCH] Fix several file processings (#2968) * Ignore image error in person * Fix hang while processing empty file --- src/remote/activitypub/models/person.ts | 4 ++-- src/services/drive/add-file.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index c359693c8..bf1df8791 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -190,7 +190,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise img == null ? Promise.resolve(null) - : resolveImage(user, img) + : resolveImage(user, img).catch(() => null) ))); const avatarId = avatar ? avatar._id : null; @@ -276,7 +276,7 @@ export async function updatePerson(uri: string, resolver?: Resolver, hint?: obje ].map(img => img == null ? Promise.resolve(null) - : resolveImage(exist, img) + : resolveImage(exist, img).catch(() => null) ))); // Update user diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index fd8be6513..830f5e043 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -185,6 +185,10 @@ export default async function( // 種類が同定できなかったら application/octet-stream にする res(['application/octet-stream', null]); } + }) + .on('end', () => { + // maybe 0 bytes + res(['application/octet-stream', null]); }); });