feat: Allow data imports larger than the standard attachment size (#4449)
* feat: Allow data imports larger than the standard attachment size * Use correct preset for data imports * Cleanup of expired attachments * lint
This commit is contained in:
31
server/queues/tasks/CleanupExpiredAttachmentsTask.ts
Normal file
31
server/queues/tasks/CleanupExpiredAttachmentsTask.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Op } from "sequelize";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import { Attachment } from "@server/models";
|
||||
import BaseTask, { TaskPriority } from "./BaseTask";
|
||||
|
||||
type Props = {
|
||||
limit: number;
|
||||
};
|
||||
|
||||
export default class CleanupExpiredAttachmentsTask extends BaseTask<Props> {
|
||||
public async perform({ limit }: Props) {
|
||||
Logger.info("task", `Deleting expired attachments…`);
|
||||
const attachments = await Attachment.unscoped().findAll({
|
||||
where: {
|
||||
expiresAt: {
|
||||
[Op.lt]: new Date(),
|
||||
},
|
||||
},
|
||||
limit,
|
||||
});
|
||||
await Promise.all(attachments.map((attachment) => attachment.destroy()));
|
||||
Logger.info("task", `Removed ${attachments.length} attachments`);
|
||||
}
|
||||
|
||||
public get options() {
|
||||
return {
|
||||
attempts: 1,
|
||||
priority: TaskPriority.Background,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user