Remove tmp file on image processing error
authorChocobozzz <me@florianbigard.com>
Mon, 15 Apr 2019 13:04:02 +0000 (15:04 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 24 Apr 2019 14:25:51 +0000 (16:25 +0200)
server/helpers/requests.ts
server/lib/activitypub/actor.ts

index 60c94da81160d327df6fc9f3e02c829eef9b11fa..8dda6c039c4705e032340f7d0cab88e1cb6f0329 100644 (file)
@@ -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
+  }
 }
 
 // ---------------------------------------------------------------------------
index 0db75906cf1019c5a2be7fd3830bf45217072ed3..25cd40905bc8f3497ff4c0d4f415918397faaf91 100644 (file)
@@ -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 }
   }
 }