summaryrefslogtreecommitdiff
path: root/src/session.ml
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-12-02 13:34:01 -0600
committerGitHub <noreply@github.com>2025-12-02 13:34:01 -0600
commitb4acb65d767c4af1f1df2b252ea9030735c08342 (patch)
tree971a0ab51a12ef1925a1c691c7bf700f9c925cb7 /src/session.ml
parent092dc65ab2197725faddbfcd2c64abb9f0151869 (diff)
parent9def9bcde17e0720283dae6822bece98983bf7ee (diff)
downloadvyconf-b4acb65d767c4af1f1df2b252ea9030735c08342.tar.gz
vyconf-b4acb65d767c4af1f1df2b252ea9030735c08342.zip
Merge pull request #37 from jestabro/vyconf-session-unsaved
T8032: add translation of cli-shell-api sessionUnsaved
Diffstat (limited to 'src/session.ml')
-rw-r--r--src/session.ml16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/session.ml b/src/session.ml
index 248121d..478c423 100644
--- a/src/session.ml
+++ b/src/session.ml
@@ -379,6 +379,18 @@ let save w s file =
| Error e -> raise (Session_error (Printf.sprintf "Error saving config: %s" e))
| Ok () -> s
+let remove_file file =
+ if Sys.file_exists file then Sys.remove file
+
+let config_unsaved w s file id =
+ let tmp_save = Printf.sprintf "/tmp/config.running_%s" id in
+ let res =
+ try
+ let _ = save w s tmp_save in
+ not (Vyos1x.Util.file_compare ~ignore_line_prefix:"//" tmp_save file)
+ with Session_error _ -> true (* false positive on unlikely error *)
+ in remove_file tmp_save; res
+
let write_running_cache w =
(* alert exn Internal.write_internal:
[Internal.Write_error] caught
@@ -480,10 +492,6 @@ let get_config w s id =
in id
let cleanup_config w id =
- let remove_file file =
- if Sys.file_exists file then
- Sys.remove file
- in
let vc = w.vyconf_config in
let running_cache = Printf.sprintf "%s_%s" vc.running_cache id in
let session_cache = Printf.sprintf "%s_%s" vc.session_cache id in