diff --git a/cdist/conf/type/__directory/gencode-remote b/cdist/conf/type/__directory/gencode-remote index ebe07318..23fa4ed3 100755 --- a/cdist/conf/type/__directory/gencode-remote +++ b/cdist/conf/type/__directory/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Steven Armstrong (steven-cdist armstrong.cc) # # This file is part of cdist. @@ -69,7 +69,7 @@ set_mode() { case "$state_should" in present) - if [ "$type" != "directory" ]; + if [ "$type" != "directory" ]; then # our destination is not a directory, remove whatever is there # and then create our directory and set all attributes set_attributes=1 diff --git a/cdist/exec/local.py b/cdist/exec/local.py index 3a3ac706..88b49be9 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -186,8 +186,13 @@ class Local(object): def save_cache(self): destination = os.path.join(self.cache_path, self.target_host) self.log.debug("Saving " + self.base_path + " to " + destination) - if os.path.exists(destination): - shutil.rmtree(destination) + + try: + if os.path.exists(destination): + shutil.rmtree(destination) + except PermissionError as e: + raise cdist.Error("Cannot delete old cache %s: %s" % (destination, e)) + shutil.move(self.base_path, destination) def _create_conf_path_and_link_conf_dirs(self): diff --git a/docs/changelog b/docs/changelog index ec584026..67eaca1a 100644 --- a/docs/changelog +++ b/docs/changelog @@ -9,6 +9,7 @@ Changelog * Type __file: Only remove file when state is absent (Steven Armstrong) * Type __link: Only remove link when state is absent (Steven Armstrong) * Type __directory: Only remove directory when state is absent (Steven Armstrong) + * Core: Fix backtrace when cache cannot be deleted 2.3.6: 2013-11-25 * New Type: __locale