From 5c4aa4f9f23440b4aa22d0e7153e8c5b181dc2fa Mon Sep 17 00:00:00 2001 From: Qingmin Duanmu Date: Fri, 10 Feb 2023 16:08:12 +0800 Subject: [PATCH] Fix FileNotFoundError for container remote sources --- openlcs/libs/common.py | 7 ++++--- openlcs/libs/sc_handler.py | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openlcs/libs/common.py b/openlcs/libs/common.py index 1c72d159..0b09442a 100644 --- a/openlcs/libs/common.py +++ b/openlcs/libs/common.py @@ -173,14 +173,15 @@ def get_component_flat(data, comp_type): return component -def uncompress_blob_gzip_files(dest_dir): +def uncompress_blob_gzip_files(src_file, dest_dir): # Uncompress the blob files that come from source container registry. # Under the directory, most of the files are gzip files that need to # decompress. There are some metadata files that no need to decompress. err_msg_list = [] - blob_files = os.listdir(dest_dir) + src_dir = os.path.dirname(src_file) + blob_files = os.listdir(src_dir) for blob_file in blob_files: - blob_file = os.path.join(dest_dir, blob_file) + blob_file = os.path.join(src_dir, blob_file) file_type = get_mime_type(blob_file) if file_type == "application/gzip": cmd = ['tar', '-xvf', blob_file] diff --git a/openlcs/libs/sc_handler.py b/openlcs/libs/sc_handler.py index fbf222d8..05f95c5b 100644 --- a/openlcs/libs/sc_handler.py +++ b/openlcs/libs/sc_handler.py @@ -167,7 +167,7 @@ def unpack_source_container_remote_source(self): uncompress_source_tarball(rs_tarball_path, rs_dest_dir) return rs_dir - def get_source_container_srpms_metadata(self): + def get_source_container_metadata(self): """ Get metadata files of source RPMs in source container. """ @@ -202,8 +202,7 @@ def unpack_source_container_image(self): for tarball in tarballs: uncompress_source_tarball(tarball) else: - self.dest_dir = os.path.dirname(self.src_file) - errs = uncompress_blob_gzip_files(self.dest_dir) + errs = uncompress_blob_gzip_files(self.src_file, self.dest_dir) # Get source RPMs in the source container. srpm_dir = self.get_source_container_srpms() @@ -212,7 +211,7 @@ def unpack_source_container_image(self): # Get metadata files of source RPMs to metadata dir, will add the # remote source metadata in this directory at the other steps. - misc_dir = self.get_source_container_srpms_metadata() + misc_dir = self.get_source_container_metadata() return srpm_dir, rs_dir, misc_dir, errs