pkgset: Only load cache once

The file in old compose does not change, there is no need to load it
again for each tag.

One consequence of this change is that the same cache will be used by
all package sets. They add stuff to the cache as they use it. However
that should not be a problem for the same reason it's okay to use the
cache in the first place. If two packages have the same path, they are
actually the same file and it's okay to reuse the data.

JIRA: COMPOSE-3374
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-03-07 14:32:12 +01:00
parent 2d39490909
commit 0fc797a06f
2 changed files with 16 additions and 5 deletions

View file

@ -236,12 +236,17 @@ class PackageSetBase(kobo.log.LoggingBase):
rpm_path = rpm_path[len(remove_path_prefix):]
f.write("%s\n" % rpm_path)
def load_old_file_cache(self, file_path):
@staticmethod
def load_old_file_cache(file_path):
"""
Loads the cached FileCache stored in pickle format in `file_path`.
"""
with open(file_path, "rb") as f:
self.old_file_cache = pickle.load(f)
return pickle.load(f)
def set_old_file_cache(self, old_file_cache):
"""Set cache of old files."""
self.old_file_cache = old_file_cache
def save_file_cache(self, file_path):
"""