refactor: handle aborted signal in all operations

This commit is contained in:
Nicolas Meienberger 2026-01-22 21:50:22 +01:00
parent 25b1bf0479
commit b7ff2f709a

View file

@ -746,6 +746,11 @@ const unlock = async (config: RepositoryConfig, options: { signal?: AbortSignal;
const res = await exec({ command: "restic", args, env, signal: options?.signal });
await cleanupTemporaryKeys(env);
if (options?.signal?.aborted) {
logger.warn("Restic unlock was aborted by signal.");
return { success: false, message: "Operation aborted" };
}
if (res.exitCode !== 0) {
logger.error(`Restic unlock failed: ${res.stderr}`);
throw new ResticError(res.exitCode, res.stderr);
@ -771,9 +776,13 @@ const check = async (
addCommonArgs(args, env, config);
const res = await exec({ command: "restic", args, env, signal: options?.signal });
await cleanupTemporaryKeys(env);
if (options?.signal?.aborted) {
logger.warn("Restic check was aborted by signal.");
return { success: false, hasErrors: true, output: "", error: "Operation aborted" };
}
const { stdout, stderr } = res;
if (res.exitCode !== 0) {
@ -807,6 +816,11 @@ const repairIndex = async (config: RepositoryConfig, options: { signal?: AbortSi
const res = await exec({ command: "restic", args, env, signal: options?.signal });
await cleanupTemporaryKeys(env);
if (options?.signal?.aborted) {
logger.warn("Restic repair index was aborted by signal.");
return { success: false, message: "Operation aborted", output: "" };
}
const { stdout, stderr } = res;
if (res.exitCode !== 0) {