aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/activitypub/playlists/create-update.ts20
-rw-r--r--server/tests/cli/prune-storage.ts4
2 files changed, 16 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 }
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index 591ed217f..5c9e023e1 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -12,6 +12,7 @@ import {
12 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
13 getAccount, 13 getAccount,
14 getEnvCli, 14 getEnvCli,
15 killallServers,
15 makeGetRequest, 16 makeGetRequest,
16 ServerInfo, 17 ServerInfo,
17 setAccessTokensToServers, 18 setAccessTokensToServers,
@@ -116,6 +117,9 @@ describe('Test prune storage scripts', function () {
116 await wait(1000) 117 await wait(1000)
117 118
118 await waitJobs(servers) 119 await waitJobs(servers)
120 killallServers(servers)
121
122 await wait(1000)
119 }) 123 })
120 124
121 it('Should have the files on the disk', async function () { 125 it('Should have the files on the disk', async function () {