refactor: warning only when backup is aborted
This commit is contained in:
parent
46c8139a23
commit
febd795517
2 changed files with 5 additions and 6 deletions
|
|
@ -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.",
|
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.",
|
12: "Wrong repository password: The provided password for the repository is incorrect.",
|
||||||
130: "Backup interrupted: The backup process was interrupted.",
|
130: "Backup interrupted: The backup process was interrupted.",
|
||||||
999: "The backup was stopped by the user.",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ResticError extends Error {
|
export class ResticError extends Error {
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
if (res.exitCode === 3) {
|
||||||
logger.error(`Restic backup encountered read errors: ${res.stderr.toString()}`);
|
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(`Restic backup failed: ${res.stderr.toString()}`);
|
||||||
logger.error(`Command executed: restic ${args.join(" ")}`);
|
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());
|
throw new ResticError(res.exitCode, res.stderr.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue