chore: merge conflicts
This commit is contained in:
parent
dc77cf6318
commit
25b1bf0479
10 changed files with 1682 additions and 17 deletions
|
|
@ -47,6 +47,7 @@ import {
|
|||
runBackupNow,
|
||||
runForget,
|
||||
setRegistrationStatus,
|
||||
startDoctor,
|
||||
stopBackup,
|
||||
tagSnapshots,
|
||||
testConnection,
|
||||
|
|
@ -144,6 +145,8 @@ import type {
|
|||
RunForgetResponse,
|
||||
SetRegistrationStatusData,
|
||||
SetRegistrationStatusResponse,
|
||||
StartDoctorData,
|
||||
StartDoctorResponse,
|
||||
StopBackupData,
|
||||
StopBackupResponse,
|
||||
TagSnapshotsData,
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ export {
|
|||
runBackupNow,
|
||||
runForget,
|
||||
setRegistrationStatus,
|
||||
startDoctor,
|
||||
stopBackup,
|
||||
tagSnapshots,
|
||||
testConnection,
|
||||
|
|
@ -189,6 +190,10 @@ export type {
|
|||
SetRegistrationStatusData,
|
||||
SetRegistrationStatusResponse,
|
||||
SetRegistrationStatusResponses,
|
||||
StartDoctorData,
|
||||
StartDoctorErrors,
|
||||
StartDoctorResponse,
|
||||
StartDoctorResponses,
|
||||
StopBackupData,
|
||||
StopBackupErrors,
|
||||
StopBackupResponse,
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ import type {
|
|||
RunForgetResponses,
|
||||
SetRegistrationStatusData,
|
||||
SetRegistrationStatusResponses,
|
||||
StartDoctorData,
|
||||
StartDoctorErrors,
|
||||
StartDoctorResponses,
|
||||
StopBackupData,
|
||||
StopBackupErrors,
|
||||
StopBackupResponses,
|
||||
|
|
|
|||
|
|
@ -927,7 +927,7 @@ export type ListRepositoriesResponses = {
|
|||
lastError: string | null;
|
||||
name: string;
|
||||
shortId: string;
|
||||
status: "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
status: "cancelled" | "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
type: "azure" | "gcs" | "local" | "r2" | "rclone" | "rest" | "s3" | "sftp";
|
||||
updatedAt: number;
|
||||
}>;
|
||||
|
|
@ -1365,7 +1365,7 @@ export type GetRepositoryResponses = {
|
|||
lastError: string | null;
|
||||
name: string;
|
||||
shortId: string;
|
||||
status: "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
status: "cancelled" | "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
type: "azure" | "gcs" | "local" | "r2" | "rclone" | "rest" | "s3" | "sftp";
|
||||
updatedAt: number;
|
||||
};
|
||||
|
|
@ -1585,7 +1585,7 @@ export type UpdateRepositoryResponses = {
|
|||
lastError: string | null;
|
||||
name: string;
|
||||
shortId: string;
|
||||
status: "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
status: "cancelled" | "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
type: "azure" | "gcs" | "local" | "r2" | "rclone" | "rest" | "s3" | "sftp";
|
||||
updatedAt: number;
|
||||
};
|
||||
|
|
@ -2051,7 +2051,7 @@ export type ListBackupSchedulesResponses = {
|
|||
lastError: string | null;
|
||||
name: string;
|
||||
shortId: string;
|
||||
status: "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
status: "cancelled" | "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
type: "azure" | "gcs" | "local" | "r2" | "rclone" | "rest" | "s3" | "sftp";
|
||||
updatedAt: number;
|
||||
};
|
||||
|
|
@ -2433,7 +2433,7 @@ export type GetBackupScheduleResponses = {
|
|||
lastError: string | null;
|
||||
name: string;
|
||||
shortId: string;
|
||||
status: "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
status: "cancelled" | "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
type: "azure" | "gcs" | "local" | "r2" | "rclone" | "rest" | "s3" | "sftp";
|
||||
updatedAt: number;
|
||||
};
|
||||
|
|
@ -2796,7 +2796,7 @@ export type GetBackupScheduleForVolumeResponses = {
|
|||
lastError: string | null;
|
||||
name: string;
|
||||
shortId: string;
|
||||
status: "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
status: "cancelled" | "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
type: "azure" | "gcs" | "local" | "r2" | "rclone" | "rest" | "s3" | "sftp";
|
||||
updatedAt: number;
|
||||
};
|
||||
|
|
@ -3367,7 +3367,7 @@ export type GetScheduleMirrorsResponses = {
|
|||
lastError: string | null;
|
||||
name: string;
|
||||
shortId: string;
|
||||
status: "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
status: "cancelled" | "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
type: "azure" | "gcs" | "local" | "r2" | "rclone" | "rest" | "s3" | "sftp";
|
||||
updatedAt: number;
|
||||
};
|
||||
|
|
@ -3587,7 +3587,7 @@ export type UpdateScheduleMirrorsResponses = {
|
|||
lastError: string | null;
|
||||
name: string;
|
||||
shortId: string;
|
||||
status: "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
status: "cancelled" | "doctor" | "error" | "healthy" | "unknown" | null;
|
||||
type: "azure" | "gcs" | "local" | "r2" | "rclone" | "rest" | "s3" | "sftp";
|
||||
updatedAt: number;
|
||||
};
|
||||
|
|
|
|||
1
app/drizzle/0043_overjoyed_shen.sql
Normal file
1
app/drizzle/0043_overjoyed_shen.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE `repositories_table` ADD `doctor_result` text;
|
||||
1635
app/drizzle/meta/0043_snapshot.json
Normal file
1635
app/drizzle/meta/0043_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -302,6 +302,13 @@
|
|||
"when": 1768687163221,
|
||||
"tag": "0042_watery_liz_osborn",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 43,
|
||||
"version": "6",
|
||||
"when": 1769085071955,
|
||||
"tag": "0043_overjoyed_shen",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -9,13 +9,15 @@ import { type } from "arktype";
|
|||
import { serverEvents } from "../../core/events";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { safeJsonParse } from "../../utils/json";
|
||||
import { getOrganizationId } from "~/server/core/request-context";
|
||||
|
||||
class AbortError extends Error {
|
||||
name = "AbortError";
|
||||
}
|
||||
|
||||
const runUnlockStep = async (config: RepositoryConfig, signal?: AbortSignal) => {
|
||||
const result = await restic.unlock(config, { signal }).then(
|
||||
const orgId = getOrganizationId();
|
||||
const result = await restic.unlock(config, { signal, organizationId: orgId }).then(
|
||||
(result) => ({ success: true, message: result.message, error: null }),
|
||||
(error) => ({ success: false, message: null, error: toMessage(error) }),
|
||||
);
|
||||
|
|
@ -29,7 +31,8 @@ const runUnlockStep = async (config: RepositoryConfig, signal?: AbortSignal) =>
|
|||
};
|
||||
|
||||
const runCheckStep = async (config: RepositoryConfig, signal: AbortSignal) => {
|
||||
const result = await restic.check(config, { readData: true, signal }).then(
|
||||
const orgId = getOrganizationId();
|
||||
const result = await restic.check(config, { readData: true, signal, organizationId: orgId }).then(
|
||||
(result) => result,
|
||||
(error) => ({ success: false, output: null, error: toMessage(error), hasErrors: true }),
|
||||
);
|
||||
|
|
@ -43,7 +46,8 @@ const runCheckStep = async (config: RepositoryConfig, signal: AbortSignal) => {
|
|||
};
|
||||
|
||||
const runRepairIndexStep = async (config: RepositoryConfig, signal: AbortSignal) => {
|
||||
const result = await restic.repairIndex(config, { signal }).then(
|
||||
const orgId = getOrganizationId();
|
||||
const result = await restic.repairIndex(config, { signal, organizationId: orgId }).then(
|
||||
(result) => ({ success: true, output: result.output, error: null }),
|
||||
(error) => ({ success: false, output: null, error: toMessage(error) }),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import crypto from "node:crypto";
|
||||
import { and, eq, or } from "drizzle-orm";
|
||||
import { InternalServerError, NotFoundError } from "http-errors-enhanced";
|
||||
import { ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced";
|
||||
import { db } from "../../db/db";
|
||||
import { repositoriesTable } from "../../db/schema";
|
||||
import { toMessage } from "../../utils/errors";
|
||||
|
|
@ -17,6 +17,11 @@ import {
|
|||
type RepositoryConfig,
|
||||
} from "~/schemas/restic";
|
||||
import { getOrganizationId } from "~/server/core/request-context";
|
||||
import { serverEvents } from "~/server/core/events";
|
||||
import { executeDoctor } from "./doctor";
|
||||
import { logger } from "~/server/utils/logger";
|
||||
|
||||
const runningDoctors = new Map<string, AbortController>();
|
||||
|
||||
const findRepository = async (idOrShortId: string) => {
|
||||
const organizationId = getOrganizationId();
|
||||
|
|
@ -345,7 +350,6 @@ const checkHealth = async (repositoryId: string) => {
|
|||
};
|
||||
|
||||
const startDoctor = async (id: string) => {
|
||||
const organizationId = getOrganizationId();
|
||||
const repository = await findRepository(id);
|
||||
|
||||
if (!repository) {
|
||||
|
|
|
|||
|
|
@ -736,7 +736,7 @@ const ls = async (config: RepositoryConfig, snapshotId: string, organizationId:
|
|||
return { snapshot, nodes };
|
||||
};
|
||||
|
||||
const unlock = async (config: RepositoryConfig, options: { signal?: AbortSignal, organizationId: string }) => {
|
||||
const unlock = async (config: RepositoryConfig, options: { signal?: AbortSignal; organizationId: string }) => {
|
||||
const repoUrl = buildRepoUrl(config);
|
||||
const env = await buildEnv(config, options.organizationId);
|
||||
|
||||
|
|
@ -755,7 +755,10 @@ const unlock = async (config: RepositoryConfig, options: { signal?: AbortSignal,
|
|||
return { success: true, message: "Repository unlocked successfully" };
|
||||
};
|
||||
|
||||
const check = async (config: RepositoryConfig, options?: { readData?: boolean; signal?: AbortSignal }) => {
|
||||
const check = async (
|
||||
config: RepositoryConfig,
|
||||
options: { readData?: boolean; signal?: AbortSignal; organizationId: string },
|
||||
) => {
|
||||
const repoUrl = buildRepoUrl(config);
|
||||
const env = await buildEnv(config, options.organizationId);
|
||||
|
||||
|
|
@ -794,9 +797,9 @@ const check = async (config: RepositoryConfig, options?: { readData?: boolean; s
|
|||
};
|
||||
};
|
||||
|
||||
const repairIndex = async (config: RepositoryConfig, options?: { signal?: AbortSignal }) => {
|
||||
const repairIndex = async (config: RepositoryConfig, options: { signal?: AbortSignal; organizationId: string }) => {
|
||||
const repoUrl = buildRepoUrl(config);
|
||||
const env = await buildEnv(config, organizationId);
|
||||
const env = await buildEnv(config, options.organizationId);
|
||||
|
||||
const args = ["repair", "index", "--repo", repoUrl];
|
||||
addCommonArgs(args, env, config);
|
||||
|
|
|
|||
Loading…
Reference in a new issue