From bba41d12254c40659f6748d7371c3bd82b59533f Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 30 Dec 2024 22:47:40 +0000 Subject: [PATCH] moved to more borg or restic exit codes solution instead of generalised --- norg/borg/create.nim | 5 ++--- norg/borg/exit_codes.nim | 15 +++++++++++++++ norg/model/exit_codes.nim | 15 --------------- 3 files changed, 17 insertions(+), 18 deletions(-) create mode 100644 norg/borg/exit_codes.nim diff --git a/norg/borg/create.nim b/norg/borg/create.nim index c778133..33a3c6a 100644 --- a/norg/borg/create.nim +++ b/norg/borg/create.nim @@ -1,10 +1,9 @@ import ../model/config_type import ../model/state_type -import ../model/exit_codes -import ../model/tool_type import ../notifier/notifier import ../model/log_type +import exit_codes import execute import prune @@ -28,7 +27,7 @@ proc createArchive(nc: NorgConfig, repo: Repository, archivename: string, retry: return (BORG_ERROR, "Max Retries Reached") else: return createArchive(nc, repo, archivename, retry + 1) - return (res.toExitCode(BORG),"Success") + return (res.toExitCode(),"Success") proc createBackup*(nc: NorgConfig, repo: Repository): EXIT_CODE = let start_time = now() diff --git a/norg/borg/exit_codes.nim b/norg/borg/exit_codes.nim new file mode 100644 index 0000000..71f1214 --- /dev/null +++ b/norg/borg/exit_codes.nim @@ -0,0 +1,15 @@ + + +import std/enumutils + +type + EXIT_CODE* = enum + BORG_SUCCESS = 0 + BORG_WARNING = 1 + BORG_ERROR = 2 + OTHER = 99 + +proc toExitCode*(i: int): EXIT_CODE = + for code in EXIT_CODE: + if i == ord(code): return code + return OTHER diff --git a/norg/model/exit_codes.nim b/norg/model/exit_codes.nim index 2167102..e69de29 100644 --- a/norg/model/exit_codes.nim +++ b/norg/model/exit_codes.nim @@ -1,15 +0,0 @@ -import tool_type - -import std/enumutils - -type - EXIT_CODE* = enum - BORG_SUCCESS = 0 - BORG_WARNING = 1 - BORG_ERROR = 2 - OTHER = 99 - -proc toExitCode*(i: int, tool: BackupTool): EXIT_CODE = - for code in EXIT_CODE: - if i == ord(code): return code - return OTHER