refactor: native repository healthcheck
This commit is contained in:
parent
803eb1cd76
commit
8e90c4ace1
1 changed files with 3 additions and 6 deletions
|
|
@ -249,21 +249,18 @@ const checkHealth = async (repositoryId: string) => {
|
||||||
throw new NotFoundError("Repository not found");
|
throw new NotFoundError("Repository not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
const { error, status } = await restic
|
const { hasErrors, error } = await restic.check(repository.config, { readData: true });
|
||||||
.snapshots(repository.config)
|
|
||||||
.then(() => ({ error: null, status: "healthy" as const }))
|
|
||||||
.catch((error) => ({ error: toMessage(error), status: "error" as const }));
|
|
||||||
|
|
||||||
await db
|
await db
|
||||||
.update(repositoriesTable)
|
.update(repositoriesTable)
|
||||||
.set({
|
.set({
|
||||||
status,
|
status: hasErrors ? "error" : "healthy",
|
||||||
lastChecked: Date.now(),
|
lastChecked: Date.now(),
|
||||||
lastError: error,
|
lastError: error,
|
||||||
})
|
})
|
||||||
.where(eq(repositoriesTable.id, repository.id));
|
.where(eq(repositoriesTable.id, repository.id));
|
||||||
|
|
||||||
return { status, lastError: error };
|
return { lastError: error };
|
||||||
};
|
};
|
||||||
|
|
||||||
const doctorRepository = async (name: string) => {
|
const doctorRepository = async (name: string) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue