aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-17 11:09:54 +0200
committerChocobozzz <me@florianbigard.com>2021-06-17 11:09:54 +0200
commit52fb1d97baa67137e3a9afadb2cc9ec2cfc04952 (patch)
treed9aa612914cef093117307cfecb7eff5310bf9eb /server/lib/activitypub
parent29b7426c671c91b8567b038df30b9ae909ee838a (diff)
downloadPeerTube-52fb1d97baa67137e3a9afadb2cc9ec2cfc04952.tar.gz
PeerTube-52fb1d97baa67137e3a9afadb2cc9ec2cfc04952.tar.zst
PeerTube-52fb1d97baa67137e3a9afadb2cc9ec2cfc04952.zip
Fix prune storage tests
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/playlists/create-update.ts20
1 files changed, 12 insertions, 8 deletions
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts
index dd4316d54..37d748de4 100644
--- a/server/lib/activitypub/playlists/create-update.ts
+++ b/server/lib/activitypub/playlists/create-update.ts
@@ -6,7 +6,7 @@ import { updatePlaylistMiniatureFromUrl } from '@server/lib/thumbnail'
6import { VideoPlaylistModel } from '@server/models/video/video-playlist' 6import { VideoPlaylistModel } from '@server/models/video/video-playlist'
7import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' 7import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
8import { FilteredModelAttributes } from '@server/types' 8import { FilteredModelAttributes } from '@server/types'
9import { MAccountDefault, MAccountId, MVideoPlaylist, MVideoPlaylistFull } from '@server/types/models' 9import { MAccountDefault, MAccountId, MThumbnail, MVideoPlaylist, MVideoPlaylistFull } from '@server/types/models'
10import { AttributesOnly } from '@shared/core-utils' 10import { AttributesOnly } from '@shared/core-utils'
11import { PlaylistObject } from '@shared/models' 11import { PlaylistObject } from '@shared/models'
12import { getOrCreateAPActor } from '../actors' 12import { getOrCreateAPActor } from '../actors'
@@ -54,11 +54,7 @@ async function createOrUpdateVideoPlaylist (playlistObject: PlaylistObject, byAc
54 // Refetch playlist from DB since elements fetching could be long in time 54 // Refetch playlist from DB since elements fetching could be long in time
55 const playlist = await VideoPlaylistModel.loadWithAccountAndChannel(upsertPlaylist.id, null) 55 const playlist = await VideoPlaylistModel.loadWithAccountAndChannel(upsertPlaylist.id, null)
56 56
57 try { 57 await updatePlaylistThumbnail(playlistObject, playlist)
58 await updatePlaylistThumbnail(playlistObject, playlist)
59 } catch (err) {
60 logger.warn('Cannot update thumbnail of %s.', playlistObject.id, { err, ...lTags(playlistObject.id, playlist.uuid, playlist.url) })
61 }
62 58
63 return rebuildVideoPlaylistElements(playlistElementUrls, playlist) 59 return rebuildVideoPlaylistElements(playlistElementUrls, playlist)
64} 60}
@@ -98,8 +94,16 @@ async function fetchElementUrls (playlistObject: PlaylistObject) {
98 94
99async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist: MVideoPlaylistFull) { 95async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist: MVideoPlaylistFull) {
100 if (playlistObject.icon) { 96 if (playlistObject.icon) {
101 const thumbnailModel = await updatePlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist }) 97 let thumbnailModel: MThumbnail
102 await playlist.setAndSaveThumbnail(thumbnailModel, undefined) 98
99 try {
100 thumbnailModel = await updatePlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist })
101 await playlist.setAndSaveThumbnail(thumbnailModel, undefined)
102 } catch (err) {
103 logger.warn('Cannot set thumbnail of %s.', playlistObject.id, { err, ...lTags(playlistObject.id, playlist.uuid, playlist.url) })
104
105 if (thumbnailModel) await thumbnailModel.removeThumbnail()
106 }
103 107
104 return 108 return
105 } 109 }