aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-08 10:37:08 +0200
committerChocobozzz <me@florianbigard.com>2018-10-08 10:37:43 +0200
commitecf3f060ef8e40846ee41c9dcdf288065f4c461d (patch)
tree53bca939b1e5ec202b2f819b596d9b1111dbe622
parent211239ed949da6b1cd4e554b374fd875e2bfb5e4 (diff)
downloadPeerTube-ecf3f060ef8e40846ee41c9dcdf288065f4c461d.tar.gz
PeerTube-ecf3f060ef8e40846ee41c9dcdf288065f4c461d.tar.zst
PeerTube-ecf3f060ef8e40846ee41c9dcdf288065f4c461d.zip
Fix avatar update
-rw-r--r--server/lib/avatar.ts3
-rw-r--r--server/models/avatar/avatar.ts5
2 files changed, 6 insertions, 2 deletions
diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts
index 4b6bc3185..021426a1a 100644
--- a/server/lib/avatar.ts
+++ b/server/lib/avatar.ts
@@ -7,10 +7,11 @@ import { AccountModel } from '../models/account/account'
7import { VideoChannelModel } from '../models/video/video-channel' 7import { VideoChannelModel } from '../models/video/video-channel'
8import { extname, join } from 'path' 8import { extname, join } from 'path'
9import { retryTransactionWrapper } from '../helpers/database-utils' 9import { retryTransactionWrapper } from '../helpers/database-utils'
10import * as uuidv4 from 'uuid/v4'
10 11
11async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) { 12async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) {
12 const extension = extname(avatarPhysicalFile.filename) 13 const extension = extname(avatarPhysicalFile.filename)
13 const avatarName = accountOrChannel.Actor.uuid + extension 14 const avatarName = uuidv4() + extension
14 const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) 15 const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName)
15 await processImage(avatarPhysicalFile, destination, AVATARS_SIZE) 16 await processImage(avatarPhysicalFile, destination, AVATARS_SIZE)
16 17
diff --git a/server/models/avatar/avatar.ts b/server/models/avatar/avatar.ts
index 5d73e24fa..303aebcc2 100644
--- a/server/models/avatar/avatar.ts
+++ b/server/models/avatar/avatar.ts
@@ -23,7 +23,10 @@ export class AvatarModel extends Model<AvatarModel> {
23 @AfterDestroy 23 @AfterDestroy
24 static removeFilesAndSendDelete (instance: AvatarModel) { 24 static removeFilesAndSendDelete (instance: AvatarModel) {
25 logger.info('Removing avatar file %s.', instance.filename) 25 logger.info('Removing avatar file %s.', instance.filename)
26 return instance.removeAvatar() 26
27 // Don't block the transaction
28 instance.removeAvatar()
29 .catch(err => logger.error('Cannot remove avatar file %s.', instance.filename, err))
27 } 30 }
28 31
29 toFormattedJSON (): Avatar { 32 toFormattedJSON (): Avatar {