Skip to content

Commit

Permalink
これでいける?
Browse files Browse the repository at this point in the history
  • Loading branch information
lqvp authored and chan-mai committed Dec 13, 2024
1 parent 85457b9 commit 6a94b9a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions packages/backend/src/core/DriveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
// リモートファイル期限切れ削除後は直リンクにする
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.accessDenied);
}

await this.driveService.deleteFile(file, false, me);
await this.driveService.deleteFileImmediately(file, false, me);
});
}
}

0 comments on commit 6a94b9a

Please sign in to comment.