From: Chocobozzz Date: Mon, 15 Apr 2019 13:04:02 +0000 (+0200) Subject: Remove tmp file on image processing error X-Git-Tag: v1.3.0-rc.1~58 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4ee7a4c9ac9280cda930a281c2d5a9a4c409cc14;p=oweals%2Fpeertube.git Remove tmp file on image processing error --- diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 60c94da81..8dda6c039 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts @@ -50,7 +50,14 @@ async function downloadImage (url: string, destDir: string, destName: string, si await doRequestAndSaveToFile({ method: 'GET', uri: url }, tmpPath) const destPath = join(destDir, destName) - await processImage({ path: tmpPath }, destPath, size) + + try { + await processImage({ path: tmpPath }, destPath, size) + } catch (err) { + await remove(tmpPath) + + throw err + } } // --------------------------------------------------------------------------- diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 0db75906c..25cd40905 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -270,7 +270,7 @@ async function refreshActorIfNeeded ( return { refreshed: true, actor } }) } catch (err) { - logger.warn('Cannot refresh actor.', { err }) + logger.warn('Cannot refresh actor %s.', actor.url, { err }) return { actor, refreshed: false } } }