From 6a94b9a3a1c6898cae527202f926ea0fcb39c364 Mon Sep 17 00:00:00 2001 From: lqvp <183242690+lqvp@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:07:26 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=93=E3=82=8C=E3=81=A7=E3=81=84=E3=81=91?= =?UTF-8?q?=E3=82=8B=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/DriveService.ts | 29 +++++++++++++++++++ .../api/endpoints/drive/files/delete.ts | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index c332e5a0a8f3..63ef839a0895 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -770,6 +770,35 @@ export class DriveService { this.deletePostProcess(file, isExpired, deleter); } + @bindThis + public async deleteFileImmediately(file: MiDriveFile, isExpired = false, deleter?: MiUser) { + if (file.storedInternal) { + // 内部ストレージのファイルを即時削除 + this.internalStorageService.del(file.accessKey!); + + if (file.thumbnailUrl) { + this.internalStorageService.del(file.thumbnailAccessKey!); + } + + if (file.webpublicUrl) { + this.internalStorageService.del(file.webpublicAccessKey!); + } + } else if (!file.isLink) { + // オブジェクトストレージのファイルを即時削除 + await this.deleteObjectStorageFile(file.accessKey!); + + if (file.thumbnailUrl) { + await this.deleteObjectStorageFile(file.thumbnailAccessKey!); + } + + if (file.webpublicUrl) { + await this.deleteObjectStorageFile(file.webpublicAccessKey!); + } + } + // 削除後の処理 + this.deletePostProcess(file, isExpired, deleter); + } + @bindThis private async deletePostProcess(file: MiDriveFile, isExpired = false, deleter?: MiUser) { // リモートファイル期限切れ削除後は直リンクにする diff --git a/packages/backend/src/server/api/endpoints/drive/files/delete.ts b/packages/backend/src/server/api/endpoints/drive/files/delete.ts index fa6e11da49e2..e6eadf31cfba 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/delete.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/delete.ts @@ -65,7 +65,7 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.accessDenied); } - await this.driveService.deleteFile(file, false, me); + await this.driveService.deleteFileImmediately(file, false, me); }); } }