diff options
author | Chocobozzz <me@florianbigard.com> | 2022-09-09 12:05:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-09-09 12:05:57 +0200 |
commit | d9dd51aec75d59bd322e249ae1c3ae98277957d3 (patch) | |
tree | f640828d9d91d3656819efe5bdaa2976adc56dea | |
parent | edacb640332eae37665551d35bf29160707336f0 (diff) | |
download | PeerTube-d9dd51aec75d59bd322e249ae1c3ae98277957d3.tar.gz PeerTube-d9dd51aec75d59bd322e249ae1c3ae98277957d3.tar.zst PeerTube-d9dd51aec75d59bd322e249ae1c3ae98277957d3.zip |
Try playlist rebuild transaction if needed
-rw-r--r-- | server/lib/activitypub/playlists/create-update.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts index c28700be6..9339e8ea4 100644 --- a/server/lib/activitypub/playlists/create-update.ts +++ b/server/lib/activitypub/playlists/create-update.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { map } from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { isArray } from '@server/helpers/custom-validators/misc' | 2 | import { isArray } from '@server/helpers/custom-validators/misc' |
3 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | ||
3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 4 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
4 | import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants' | 5 | import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants' |
5 | import { sequelizeTypescript } from '@server/initializers/database' | 6 | import { sequelizeTypescript } from '@server/initializers/database' |
@@ -124,13 +125,13 @@ async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist | |||
124 | async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MVideoPlaylist) { | 125 | async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MVideoPlaylist) { |
125 | const elementsToCreate = await buildElementsDBAttributes(elementUrls, playlist) | 126 | const elementsToCreate = await buildElementsDBAttributes(elementUrls, playlist) |
126 | 127 | ||
127 | await sequelizeTypescript.transaction(async t => { | 128 | await retryTransactionWrapper(() => sequelizeTypescript.transaction(async t => { |
128 | await VideoPlaylistElementModel.deleteAllOf(playlist.id, t) | 129 | await VideoPlaylistElementModel.deleteAllOf(playlist.id, t) |
129 | 130 | ||
130 | for (const element of elementsToCreate) { | 131 | for (const element of elementsToCreate) { |
131 | await VideoPlaylistElementModel.create(element, { transaction: t }) | 132 | await VideoPlaylistElementModel.create(element, { transaction: t }) |
132 | } | 133 | } |
133 | }) | 134 | })) |
134 | 135 | ||
135 | logger.info('Rebuilt playlist %s with %s elements.', playlist.url, elementsToCreate.length, lTags(playlist.uuid, playlist.url)) | 136 | logger.info('Rebuilt playlist %s with %s elements.', playlist.url, elementsToCreate.length, lTags(playlist.uuid, playlist.url)) |
136 | 137 | ||