summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2009-11-25 15:45:54 -0600
committerClark Williams <williams@redhat.com>2009-11-25 15:50:50 -0600
commit6bbecd75ebd1d9c484387f2a77443205bfb34b6f (patch)
tree8a9c6c76ff3c9fe1e4f8ac4f1a6dfecae6935386
parentf7b4f6cb7ff4330ce7359d1036a771363837d046 (diff)
downloadmock-6bbecd75ebd1d9c484387f2a77443205bfb34b6f.tar.gz
mock-6bbecd75ebd1d9c484387f2a77443205bfb34b6f.tar.xz
mock-6bbecd75ebd1d9c484387f2a77443205bfb34b6f.zip
fix intermittent problems generating root cache tarball (BZ# 540997)
Patch submitted by Paul Howarth <paul@city-fan.org> to prevent race condition when creating root cache tarballs and to remove partial tarballs on error. Signed-off-by: Clark Williams <williams@redhat.com> CC: Paul Howarth <paul@city-fan.org>
-rw-r--r--py/mock/plugins/root_cache.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/py/mock/plugins/root_cache.py b/py/mock/plugins/root_cache.py
index 8756c01..ffed12e 100644
--- a/py/mock/plugins/root_cache.py
+++ b/py/mock/plugins/root_cache.py
@@ -109,11 +109,18 @@ class RootCache(object):
# never rebuild cache unless it was a clean build.
if self.rootObj.chrootWasCleaned:
+ mock.util.do(["sync"], shell=False)
self.state("creating cache")
- mock.util.do(
- ["tar"] + self.compressArgs + ["-cf", self.rootCacheFile,
- "-C", self.rootObj.makeChrootPath(), "."],
- shell=False
- )
+ try:
+ mock.util.do(
+ ["tar"] + self.compressArgs + ["-cf", self.rootCacheFile,
+ "-C", self.rootObj.makeChrootPath(),
+ "."],
+ shell=False
+ )
+ except:
+ if os.path.exists(self.rootCacheFile):
+ os.remove(self.rootCacheFile)
+ raise
finally:
self._rootCacheUnlock()