Skip to content

Commit

Permalink
Merge pull request #52 from team-shahu/feat/object-storage-delete-files
Browse files Browse the repository at this point in the history
feat: ドライブで削除したファイルをオブジェクトストレージ上でも削除するように
  • Loading branch information
chan-mai authored Dec 13, 2024
2 parents cd84f9c + 06af836 commit 1d64401
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- 独自機能ページの追加 https://github.com/team-shahu/misskey/pull/42
- 予約投稿機能 https://github.com/team-shahu/misskey/pull/46 https://github.com/team-shahu/misskey/pull/49 https://github.com/team-shahu/misskey/pull/51
- フォロー/フォロリクの履歴 https://github.com/team-shahu/misskey/pull/49 https://github.com/team-shahu/misskey/pull/50
- ドライブから削除したファイルをオブジェクトストレージからも葬るように https://github.com/team-shahu/misskey/pull/49 https://github.com/team-shahu/misskey/pull/52

## Special Thanks
- [Misskey](https://github.com/misskey-dev/misskey)
Expand Down
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 1d64401

Please sign in to comment.