summaryrefslogtreecommitdiff
path: root/src/queue/processors/object-storage/clean-remote-files.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-11-12 02:02:25 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2021-11-12 02:02:25 +0900
commit0e4a111f81cceed275d9bec2695f6e401fb654d8 (patch)
tree40874799472fa07416f17b50a398ac33b7771905 /src/queue/processors/object-storage/clean-remote-files.ts
parentupdate deps (diff)
downloadmisskey-0e4a111f81cceed275d9bec2695f6e401fb654d8.tar.gz
misskey-0e4a111f81cceed275d9bec2695f6e401fb654d8.tar.bz2
misskey-0e4a111f81cceed275d9bec2695f6e401fb654d8.zip
refactoring
Resolve #7779
Diffstat (limited to 'src/queue/processors/object-storage/clean-remote-files.ts')
-rw-r--r--src/queue/processors/object-storage/clean-remote-files.ts50
1 files changed, 0 insertions, 50 deletions
diff --git a/src/queue/processors/object-storage/clean-remote-files.ts b/src/queue/processors/object-storage/clean-remote-files.ts
deleted file mode 100644
index 3b2e4ea939..0000000000
--- a/src/queue/processors/object-storage/clean-remote-files.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import * as Bull from 'bull';
-
-import { queueLogger } from '../../logger';
-import { deleteFileSync } from '@/services/drive/delete-file';
-import { DriveFiles } from '@/models/index';
-import { MoreThan, Not, IsNull } from 'typeorm';
-
-const logger = queueLogger.createSubLogger('clean-remote-files');
-
-export default async function cleanRemoteFiles(job: Bull.Job<{}>, done: any): Promise<void> {
- logger.info(`Deleting cached remote files...`);
-
- let deletedCount = 0;
- let cursor: any = null;
-
- while (true) {
- const files = await DriveFiles.find({
- where: {
- userHost: Not(IsNull()),
- isLink: false,
- ...(cursor ? { id: MoreThan(cursor) } : {})
- },
- take: 8,
- order: {
- id: 1
- }
- });
-
- if (files.length === 0) {
- job.progress(100);
- break;
- }
-
- cursor = files[files.length - 1].id;
-
- await Promise.all(files.map(file => deleteFileSync(file, true)));
-
- deletedCount += 8;
-
- const total = await DriveFiles.count({
- userHost: Not(IsNull()),
- isLink: false,
- });
-
- job.progress(deletedCount / total);
- }
-
- logger.succ(`All cahced remote files has been deleted.`);
- done();
-}