delete old emoji file when replaced - fixes #608

it's the same code that 5f7fc54ee9 added
to `delete` and `deleteBulk`, with the extra check that we're not
deleting the same file we're setting
This commit is contained in:
dakkar 2024-08-05 09:27:06 +01:00
parent 5496aa27db
commit 1e86cba7dc

View file

@ -142,6 +142,13 @@ export class CustomEmojiService implements OnApplicationShutdown {
this.localEmojisCache.refresh(); this.localEmojisCache.refresh();
if (data.driveFile != null) {
const file = await this.driveFilesRepository.findOneBy({ url: emoji.originalUrl, userHost: emoji.host ? emoji.host : IsNull() });
if (file && file.id != data.driveFile.id) {
await this.driveService.deleteFile(file, false, moderator ? moderator : undefined);
}
}
const packed = await this.emojiEntityService.packDetailed(emoji.id); const packed = await this.emojiEntityService.packDetailed(emoji.id);
if (emoji.name === data.name) { if (emoji.name === data.name) {