feat: admin to remove repo cache

This commit is contained in:
tdurieux
2023-02-07 13:27:06 +01:00
parent 3eee62d6ad
commit 73f7582fd2
6 changed files with 162 additions and 10 deletions

View File

@@ -0,0 +1,22 @@
import { SandboxedJob } from "bullmq";
import Repository from "../Repository";
export default async function (job: SandboxedJob<Repository, void>) {
const { connect, getRepository } = require("../database/database");
try {
await connect();
console.log(
`[QUEUE] Cache of ${job.data.repoId} is going to be removed...`
);
const repo = await getRepository(job.data.repoId);
try {
await repo.removeCache();
} catch (error) {
throw error;
}
} catch (error) {
console.error(error);
} finally {
console.log(`[QUEUE] Cache of ${job.data.repoId} is removed.`);
}
}