File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ import { AccountModel } from '../models/account/account'
7
7
import { VideoChannelModel } from '../models/video/video-channel'
8
8
import { extname , join } from 'path'
9
9
import { retryTransactionWrapper } from '../helpers/database-utils'
10
+ import * as uuidv4 from 'uuid/v4'
10
11
11
12
async function updateActorAvatarFile ( avatarPhysicalFile : Express . Multer . File , accountOrChannel : AccountModel | VideoChannelModel ) {
12
13
const extension = extname ( avatarPhysicalFile . filename )
13
- const avatarName = accountOrChannel . Actor . uuid + extension
14
+ const avatarName = uuidv4 ( ) + extension
14
15
const destination = join ( CONFIG . STORAGE . AVATARS_DIR , avatarName )
15
16
await processImage ( avatarPhysicalFile , destination , AVATARS_SIZE )
16
17
Original file line number Diff line number Diff line change @@ -23,7 +23,10 @@ export class AvatarModel extends Model<AvatarModel> {
23
23
@AfterDestroy
24
24
static removeFilesAndSendDelete ( instance : AvatarModel ) {
25
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
32
toFormattedJSON ( ) : Avatar {
You can’t perform that action at this time.
0 commit comments