From 6bf4f33fbe8a7b2d6590fd19aa18f4defc54acb1 Mon Sep 17 00:00:00 2001 From: spiralvoice Date: Sat, 23 Oct 2010 18:22:29 +0000 Subject: [PATCH] patch #7356 --- distrib/ChangeLog | 1 + src/utils/lib/options.ml4 | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/distrib/ChangeLog b/distrib/ChangeLog index 8868c378..eb36334e 100644 --- a/distrib/ChangeLog +++ b/distrib/ChangeLog @@ -15,6 +15,7 @@ ChangeLog ========= 2010/10/23 +7356: options: ensure that tmp file is removed (ygrek) 7355: DC web ui: escape commands' arguments (ygrek) 7354: DC: cleanup temporary files (ygrek) 7353: DC: silence "ADC not supported" message (ygrek) diff --git a/src/utils/lib/options.ml4 b/src/utils/lib/options.ml4 index fe8d8f80..647031ae 100644 --- a/src/utils/lib/options.ml4 +++ b/src/utils/lib/options.ml4 @@ -851,10 +851,10 @@ let save opfile = if not (Sys.file_exists old_config_dir) then Unix.mkdir old_config_dir 0o755; let filename = opfile.file_name in - let temp_file = filename ^ ".tmp" in let old_file = Filename.concat old_config_dir filename in try + Unix2.with_remove (filename ^ ".tmp") begin fun temp_file -> Unix2.tryopen_write temp_file (fun oc -> (* race! *) if !save_private then (try Unix.chmod temp_file 0o600 with _ -> ()); @@ -951,6 +951,7 @@ let save opfile = with e -> lprintf_nl "[Opt] exception %s while saving %s" (Printexc2.to_string e) filename ); + end; (* remove temp_file *) opfile.file_after_save_hook (); with e -> opfile.file_after_save_hook (); -- 2.11.4.GIT