diff options
author | Clark Williams <williams@redhat.com> | 2009-11-25 15:45:54 -0600 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2009-11-25 15:50:50 -0600 |
commit | 6bbecd75ebd1d9c484387f2a77443205bfb34b6f (patch) | |
tree | 8a9c6c76ff3c9fe1e4f8ac4f1a6dfecae6935386 /py | |
parent | f7b4f6cb7ff4330ce7359d1036a771363837d046 (diff) | |
download | mock-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>
Diffstat (limited to 'py')
-rw-r--r-- | py/mock/plugins/root_cache.py | 17 |
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() |