aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-09-09 12:05:35 +0200
committerChocobozzz <me@florianbigard.com>2022-09-09 12:05:57 +0200
commitd9dd51aec75d59bd322e249ae1c3ae98277957d3 (patch)
treef640828d9d91d3656819efe5bdaa2976adc56dea /server/lib/activitypub
parentedacb640332eae37665551d35bf29160707336f0 (diff)
downloadPeerTube-d9dd51aec75d59bd322e249ae1c3ae98277957d3.tar.gz
PeerTube-d9dd51aec75d59bd322e249ae1c3ae98277957d3.tar.zst
PeerTube-d9dd51aec75d59bd322e249ae1c3ae98277957d3.zip
Try playlist rebuild transaction if needed
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/playlists/create-update.ts5
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 @@
1import { map } from 'bluebird' 1import { map } from 'bluebird'
2import { isArray } from '@server/helpers/custom-validators/misc' 2import { isArray } from '@server/helpers/custom-validators/misc'
3import { retryTransactionWrapper } from '@server/helpers/database-utils'
3import { logger, loggerTagsFactory } from '@server/helpers/logger' 4import { logger, loggerTagsFactory } from '@server/helpers/logger'
4import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants' 5import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants'
5import { sequelizeTypescript } from '@server/initializers/database' 6import { sequelizeTypescript } from '@server/initializers/database'
@@ -124,13 +125,13 @@ async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist
124async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MVideoPlaylist) { 125async 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