Fix cache problem (Resolves: rhbz#1155185)

This commit is contained in:
Michal Srb 2014-11-12 19:07:24 +01:00
parent 532a3d6f1c
commit 8b7596336b
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,42 @@
diff --git a/python/javapackages/common/util.py b/python/javapackages/common/util.py
index 071805f..325650a 100644
--- a/python/javapackages/common/util.py
+++ b/python/javapackages/common/util.py
@@ -44,7 +44,7 @@ def kill_parent_process():
def get_cachedir(path, create_if_not_exists=True):
cachedir_path = os.path.join(path, ".javapackages_cache")
if not os.path.exists(cachedir_path) and create_if_not_exists:
- os.mkdir(cachedir_path)
+ os.makedirs(cachedir_path)
return cachedir_path
diff --git a/python/javapackages/metadata/metadata.py b/python/javapackages/metadata/metadata.py
index 5b507e3..a0485d1 100644
--- a/python/javapackages/metadata/metadata.py
+++ b/python/javapackages/metadata/metadata.py
@@ -250,7 +250,8 @@ class Metadata(object):
def _write_cache_file(self, cachefile, content):
try:
cachefile = open(cachefile, 'wb')
- pickle.dump(content, cachefile)
+ cache = (os.getppid(), content)
+ pickle.dump(cache, cachefile)
cachefile.close()
except IOError:
return None
@@ -260,8 +261,12 @@ class Metadata(object):
def _read_cache_file(cachefile):
try:
cachefile = open(cachefile, 'rb')
- content = pickle.load(cachefile)
+ cache = pickle.load(cachefile)
cachefile.close()
+ # check if the cache was most likely created during current build
+ if cache[0] != os.getppid():
+ logging.warning("Cache is outdated, skipping")
+ return None
except IOError:
return None
- return content
+ return cache[1]

View File

@ -7,7 +7,7 @@
Name: javapackages-tools
Version: 4.2.0
Release: 5%{?dist}
Release: 6%{?dist}
Summary: Macros and scripts for Java packaging support
@ -19,6 +19,7 @@ Patch1: 0001-metadata-Read-OSGi-Requires-from-manifest-only-if-os.patch
Patch2: 0001-pom_editor-Fix-missing-space-between-xmlns-declarati.patch
Patch3: 0002-Use-wrapper-script-to-inject-extra-JVM-arguments.patch
Patch4: 0003-Use-architecture-independent-location-of-abrt-java-c.patch
Patch5: 0001-fix-rhbz#1155185.patch
BuildArch: noarch
@ -175,6 +176,7 @@ This package provides non-essential macros and scripts to support Java packaging
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%if 0%{?with_python3}
find . -name '*.py' | xargs sed -i '1s|^#!.*python|#!%{__python3}|'
@ -240,6 +242,9 @@ popd
%doc LICENSE
%changelog
* Wed Nov 12 2014 Michal Srb <msrb@redhat.com> - 4.2.0-6
- Fix cache problem (Resolves: rhbz#1155185)
* Thu Oct 30 2014 Mikolaj Izdebski <mizdebsk@redhat.com> - 4.2.0-5
- Use wrapper script to inject ABRT agent JVM argument
- Fix path to ABRT agent DSO