catch permissionserror when deleting old cache
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
48923d23d8
commit
7cf0d60b08
1 changed files with 7 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue