Module: check_mk
Branch: master
Commit: 06fb9b763a57c1aaf40948fb46988263a92467b5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=06fb9b763a57c1…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Oct 27 10:42:26 2017 +0200
Fixed possible exception related to "tmp_path" vari able in case of locking
issues during saving
Change-Id: Ib9f61097dd04176ed77a1836a2cb917529a70012
---
lib/store.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/store.py b/lib/store.py
index f88545d..5efbc45 100644
--- a/lib/store.py
+++ b/lib/store.py
@@ -154,13 +154,14 @@ def save_data_to_file(path, data, pretty=True):
# Then the new file is written to a temporary file and moved to the target path
def save_file(path, content, mode=0660):
try:
+ tmp_path = None
+
# Normally the file is already locked (when data has been loaded before with
lock=True),
# but lock it just to be sure we have the lock on the file.
#
# Please note that this already creates the file with 0 bytes (in case it is
missing).
aquire_lock(path)
- tmp_path = None
with tempfile.NamedTemporaryFile("w", dir=os.path.dirname(path),
prefix=".%s.new" %
os.path.basename(path),
delete=False) as tmp: