improve error handling during the download process

This commit is contained in:
tdurieux
2023-05-31 11:46:20 +02:00
parent 0997e19d3d
commit 406330d957
+4 -4
View File
@@ -18,10 +18,11 @@ export default async function (job: SandboxedJob<Repository, void>) {
await connect(); await connect();
const repo = await getRepository(job.data.repoId); const repo = await getRepository(job.data.repoId);
job.updateProgress({ status: "get_repo" }); job.updateProgress({ status: "get_repo" });
await repo.resetSate(RepositoryStatus.PREPARING, "");
job.updateProgress({ status: "resetSate" });
try { try {
await repo.resetSate(RepositoryStatus.PREPARING, "");
job.updateProgress({ status: "resetSate" });
await repo.anonymize(); await repo.anonymize();
console.log(`[QUEUE] ${job.data.repoId} is downloaded`);
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
await repo.updateStatus(RepositoryStatus.ERROR, error.message); await repo.updateStatus(RepositoryStatus.ERROR, error.message);
@@ -32,7 +33,6 @@ export default async function (job: SandboxedJob<Repository, void>) {
} }
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} finally { console.log(`[QUEUE] ${job.data.repoId} is finished with an error`);
console.log(`[QUEUE] ${job.data.repoId} is downloaded`);
} }
} }