refactor: warning only when backup is aborted
Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled

This commit is contained in:
Nicolas Meienberger 2025-12-19 23:30:23 +01:00
parent 46c8139a23
commit febd795517
2 changed files with 5 additions and 6 deletions

View file

@ -26,7 +26,6 @@ const resticErrorCodes: Record<number, string> = {
11: "Failed to lock repository: Unable to acquire a lock on the repository. Try to run doctor on the repository.",
12: "Wrong repository password: The provided password for the repository is incorrect.",
130: "Backup interrupted: The backup process was interrupted.",
999: "The backup was stopped by the user.",
};
export class ResticError extends Error {

View file

@ -337,6 +337,11 @@ const backup = async (
},
});
if (options?.signal?.aborted) {
logger.warn("Restic backup was aborted by signal.");
return { result: null, exitCode: res.exitCode };
}
if (res.exitCode === 3) {
logger.error(`Restic backup encountered read errors: ${res.stderr.toString()}`);
}
@ -345,11 +350,6 @@ const backup = async (
logger.error(`Restic backup failed: ${res.stderr.toString()}`);
logger.error(`Command executed: restic ${args.join(" ")}`);
if (options?.signal?.aborted) {
logger.error("Restic backup was aborted by signal.");
throw new ResticError(999, "Backup operation stopped by user.");
}
throw new ResticError(res.exitCode, res.stderr.toString());
}