mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
refactor: native repository healthcheck
This commit is contained in:
@@ -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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user