diff options
Diffstat (limited to 'server/lib/avatar.ts')
-rw-r--r-- | server/lib/avatar.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts index 14f0a05f5..4b6bc3185 100644 --- a/server/lib/avatar.ts +++ b/server/lib/avatar.ts | |||
@@ -6,6 +6,7 @@ import { processImage } from '../helpers/image-utils' | |||
6 | import { AccountModel } from '../models/account/account' | 6 | import { AccountModel } from '../models/account/account' |
7 | import { VideoChannelModel } from '../models/video/video-channel' | 7 | import { VideoChannelModel } from '../models/video/video-channel' |
8 | import { extname, join } from 'path' | 8 | import { extname, join } from 'path' |
9 | import { retryTransactionWrapper } from '../helpers/database-utils' | ||
9 | 10 | ||
10 | async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) { | 11 | async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) { |
11 | const extension = extname(avatarPhysicalFile.filename) | 12 | const extension = extname(avatarPhysicalFile.filename) |
@@ -13,13 +14,15 @@ async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, a | |||
13 | const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) | 14 | const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) |
14 | await processImage(avatarPhysicalFile, destination, AVATARS_SIZE) | 15 | await processImage(avatarPhysicalFile, destination, AVATARS_SIZE) |
15 | 16 | ||
16 | return sequelizeTypescript.transaction(async t => { | 17 | return retryTransactionWrapper(() => { |
17 | const updatedActor = await updateActorAvatarInstance(accountOrChannel.Actor, avatarName, t) | 18 | return sequelizeTypescript.transaction(async t => { |
18 | await updatedActor.save({ transaction: t }) | 19 | const updatedActor = await updateActorAvatarInstance(accountOrChannel.Actor, avatarName, t) |
20 | await updatedActor.save({ transaction: t }) | ||
19 | 21 | ||
20 | await sendUpdateActor(accountOrChannel, t) | 22 | await sendUpdateActor(accountOrChannel, t) |
21 | 23 | ||
22 | return updatedActor.Avatar | 24 | return updatedActor.Avatar |
25 | }) | ||
23 | }) | 26 | }) |
24 | } | 27 | } |
25 | 28 | ||