commit cac6f209ab9591055f99eecb24d61866b626aded
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Mon Dec 3 10:08:07 2012 +0100
ResourceCache: Fixing cache inconsistency resolution
lnst-slave crashed every time an inconsistency between cache index
and the actual cached files happened. More precisely when a file
existed but an appropriate record was not in the index.
It will now be deleted and replaced with a new file from the controller
issuing the request.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
lnst/Common/ResourceCache.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Common/ResourceCache.py b/lnst/Common/ResourceCache.py
index 7cf2f0e..9563d8c 100644
--- a/lnst/Common/ResourceCache.py
+++ b/lnst/Common/ResourceCache.py
@@ -88,7 +88,13 @@ class ResourceCache(object):
raise ResourceCacheError("File already in cache")
entry_dir = "%s/%s" % (self._root, entry_hash)
- os.mkdir(entry_dir)
+ if os.path.exists(entry_dir):
+ try:
+ shutil.rmtree(entry_dir)
+ except OSError as e:
+ if e.errno != 2:
+ raise
+ os.makedirs(entry_dir)
shutil.move(filepath, entry_dir)
entry_path = "%s/%s" % (entry_dir, os.path.basename(filepath))
Show replies by date