mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-25 16:35:13 +00:00
feat: admin to remove repo cache
This commit is contained in:
22
src/processes/removeCache.ts
Normal file
22
src/processes/removeCache.ts
Normal 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.`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user