diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-17 11:09:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-17 11:09:54 +0200 |
commit | 52fb1d97baa67137e3a9afadb2cc9ec2cfc04952 (patch) | |
tree | d9aa612914cef093117307cfecb7eff5310bf9eb | |
parent | 29b7426c671c91b8567b038df30b9ae909ee838a (diff) | |
download | PeerTube-52fb1d97baa67137e3a9afadb2cc9ec2cfc04952.tar.gz PeerTube-52fb1d97baa67137e3a9afadb2cc9ec2cfc04952.tar.zst PeerTube-52fb1d97baa67137e3a9afadb2cc9ec2cfc04952.zip |
Fix prune storage tests
-rw-r--r-- | server/lib/activitypub/playlists/create-update.ts | 20 | ||||
-rw-r--r-- | server/tests/cli/prune-storage.ts | 4 |
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' | |||
6 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 6 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
7 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' | 7 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' |
8 | import { FilteredModelAttributes } from '@server/types' | 8 | import { FilteredModelAttributes } from '@server/types' |
9 | import { MAccountDefault, MAccountId, MVideoPlaylist, MVideoPlaylistFull } from '@server/types/models' | 9 | import { MAccountDefault, MAccountId, MThumbnail, MVideoPlaylist, MVideoPlaylistFull } from '@server/types/models' |
10 | import { AttributesOnly } from '@shared/core-utils' | 10 | import { AttributesOnly } from '@shared/core-utils' |
11 | import { PlaylistObject } from '@shared/models' | 11 | import { PlaylistObject } from '@shared/models' |
12 | import { getOrCreateAPActor } from '../actors' | 12 | import { 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 | ||
99 | async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist: MVideoPlaylistFull) { | 95 | async 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 () { |