Fix 500 when adding video in playlist
authorChocobozzz <me@florianbigard.com>
Thu, 19 Mar 2020 08:46:50 +0000 (09:46 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 19 Mar 2020 08:46:50 +0000 (09:46 +0100)
server/controllers/api/video-playlist.ts

index b51490bf914f599c301c1796dfc89f3e25938158..aa9053372cf00ef7e070f447cccd460436662dc0 100644 (file)
@@ -463,7 +463,13 @@ async function regeneratePlaylistThumbnail (videoPlaylist: MVideoPlaylistThumbna
 async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbnail, video: MVideoThumbnail) {
   logger.info('Generating default thumbnail to playlist %s.', videoPlaylist.url)
 
-  const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, video.getMiniature().filename)
+  const videoMiniature = video.getMiniature()
+  if (!videoMiniature) {
+    logger.info('Cannot generate thumbnail for playlist %s because video %s does not have any.', videoPlaylist.url, video.url)
+    return
+  }
+
+  const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename)
   const thumbnailModel = await createPlaylistMiniatureFromExisting(inputPath, videoPlaylist, true, true)
 
   thumbnailModel.videoPlaylistId = videoPlaylist.id