aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-02-06 17:39:19 +0100
committerChocobozzz <me@florianbigard.com>2020-02-06 17:39:19 +0100
commit6872996d296d5b8024c569fce426562fac2f64bf (patch)
tree43c7e1c5c0e28973929e3ac817c391da814a6ed0 /server/lib
parenta3b7421abb4192e215aa280418b62e96958c5e42 (diff)
downloadPeerTube-6872996d296d5b8024c569fce426562fac2f64bf.tar.gz
PeerTube-6872996d296d5b8024c569fce426562fac2f64bf.tar.zst
PeerTube-6872996d296d5b8024c569fce426562fac2f64bf.zip
Be more robust with missing thumbnails/previews
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/videos.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 7d8296e45..7386c2e53 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -340,9 +340,11 @@ async function updateVideoFromAP (options: {
340 340
341 if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel, t) 341 if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel, t)
342 342
343 const previewUrl = videoUpdated.getPreview().getFileUrl(videoUpdated) 343 if (videoUpdated.getPreview()) {
344 const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE) 344 const previewUrl = videoUpdated.getPreview().getFileUrl(videoUpdated)
345 await videoUpdated.addAndSaveThumbnail(previewModel, t) 345 const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE)
346 await videoUpdated.addAndSaveThumbnail(previewModel, t)
347 }
346 348
347 { 349 {
348 const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoUpdated, videoObject.url) 350 const videoFileAttributes = videoFileActivityUrlToDBAttributes(videoUpdated, videoObject.url)
@@ -531,6 +533,10 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc
531 const video = VideoModel.build(videoData) as MVideoThumbnail 533 const video = VideoModel.build(videoData) as MVideoThumbnail
532 534
533 const promiseThumbnail = createVideoMiniatureFromUrl(getThumbnailFromIcons(videoObject).url, video, ThumbnailType.MINIATURE) 535 const promiseThumbnail = createVideoMiniatureFromUrl(getThumbnailFromIcons(videoObject).url, video, ThumbnailType.MINIATURE)
536 .catch(err => {
537 logger.error('Cannot create miniature from url.', { err })
538 return undefined
539 })
534 540
535 let thumbnailModel: MThumbnail 541 let thumbnailModel: MThumbnail
536 if (waitThumbnail === true) { 542 if (waitThumbnail === true) {
@@ -602,11 +608,15 @@ async function createVideo (videoObject: VideoTorrentObject, channel: MChannelAc
602 }) 608 })
603 609
604 if (waitThumbnail === false) { 610 if (waitThumbnail === false) {
611 // Error is already caught above
612 // eslint-disable-next-line @typescript-eslint/no-floating-promises
605 promiseThumbnail.then(thumbnailModel => { 613 promiseThumbnail.then(thumbnailModel => {
614 if (!thumbnailModel) return
615
606 thumbnailModel = videoCreated.id 616 thumbnailModel = videoCreated.id
607 617
608 return thumbnailModel.save() 618 return thumbnailModel.save()
609 }).catch(err => logger.error('Cannot create miniature from url.', { err })) 619 })
610 } 620 }
611 621
612 return { autoBlacklisted, videoCreated } 622 return { autoBlacklisted, videoCreated }