From 3b91ace4ea0069fcd1f424295379a43300c588ec Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 10 Jul 2016 21:28:30 +0200 Subject: [PATCH] Additionaly improve hostdir fix. --- cdist/exec/local.py | 13 ++++++++----- docs/changelog | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index cc905751..6d7ccc57 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -62,9 +62,11 @@ class Local(object): base_path_parent = tempfile.mkdtemp() # TODO: the below atexit hook nukes any debug info we would have # if cdist exits with error. - #import atexit - #atexit.register(lambda: shutil.rmtree(base_path_parent)) + # import atexit + # atexit.register(lambda: shutil.rmtree(base_path_parent)) self.hostdir = self._hostdir() + self.log.debug("Calculated temp dir for target \"{}\" is " + "\"{}\"".format(self.target_host, self.hostdir)) self.base_path = os.path.join(base_path_parent, self.hostdir) self._init_log() @@ -97,8 +99,9 @@ class Local(object): return None def _hostdir(self): - # Do not assume target_host is anything that can be used as a directory name. - # Instead use a hash, which is know to work as directory name. + # Do not assume target_host is anything that can be used as a + # directory name. + # Instead use a hash, which is known to work as directory name. return hashlib.md5(self.target_host.encode('utf-8')).hexdigest() def _init_log(self): @@ -239,7 +242,7 @@ class Local(object): message_prefix=message_prefix) def save_cache(self): - destination = os.path.join(self.cache_path, self.target_host) + destination = os.path.join(self.cache_path, self.hostdir) self.log.debug("Saving " + self.base_path + " to " + destination) try: diff --git a/docs/changelog b/docs/changelog index a5b1a6c3..a07a90bc 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,6 +2,7 @@ Changelog --------- next: + * Core: Fix hostdir: use hash instead of target host (Steven Armstrong) * Core: pep8 (Darko Poljak) * Documentation: Restructure and fix and improve docs and manpages (Darko Poljak) * Core: Add files directory for static files (Darko Poljak)