The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/server/cron/temporaryUploadsCleanup.ts

16 lines
578 B

import { cronJobs } from '@rocket.chat/cron';
import { Uploads } from '@rocket.chat/models';
import { FileUpload } from '../../app/file-upload/server';
async function temporaryUploadCleanup(): Promise<void> {
const files = await Uploads.findExpiredTemporaryFiles({ projection: { _id: 1 } }).toArray();
for await (const file of files) {
await FileUpload.getStore('Uploads').deleteById(file._id);
}
}
export async function temporaryUploadCleanupCron(): Promise<void> {
return cronJobs.add('temporaryUploadCleanup', '31 * * * *', async () => temporaryUploadCleanup());
}