// Check the rights
asyncMiddleware(videoChannelsUpdateValidator),
updateAvatarValidator,
- asyncRetryTransactionMiddleware(updateVideoChannelAvatar)
+ asyncMiddleware(updateVideoChannelAvatar)
)
videoChannelRouter.put('/:nameWithHost',
import { AccountModel } from '../models/account/account'
import { VideoChannelModel } from '../models/video/video-channel'
import { extname, join } from 'path'
+import { retryTransactionWrapper } from '../helpers/database-utils'
async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) {
const extension = extname(avatarPhysicalFile.filename)
const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName)
await processImage(avatarPhysicalFile, destination, AVATARS_SIZE)
- return sequelizeTypescript.transaction(async t => {
- const updatedActor = await updateActorAvatarInstance(accountOrChannel.Actor, avatarName, t)
- await updatedActor.save({ transaction: t })
+ return retryTransactionWrapper(() => {
+ return sequelizeTypescript.transaction(async t => {
+ const updatedActor = await updateActorAvatarInstance(accountOrChannel.Actor, avatarName, t)
+ await updatedActor.save({ transaction: t })
- await sendUpdateActor(accountOrChannel, t)
+ await sendUpdateActor(accountOrChannel, t)
- return updatedActor.Avatar
+ return updatedActor.Avatar
+ })
})
}