tacker.common.csar_utils module

class tacker.common.csar_utils.PreserveZipFilePermissions(file, mode='r', compression=0, allowZip64=True, compresslevel=None, *, strict_timestamps=True, metadata_encoding=None)

Bases: ZipFile

Patched _extract_member function of zipFile.

zipfile.ZipFile.extractall function internally calls _extract_member function. Here _extract_member function is patched to retain the file permissions using member.external_attr >> 16.

Note: First 16 bits of external_attr store permission details.

tacker.common.csar_utils.delete_csar_data(package_uuid)
tacker.common.csar_utils.extract_csar_zip_file(file_path, extract_path)
tacker.common.csar_utils.extract_csar_zip_file_with_disk_check(file_path, extract_path)

Extract CSAR members with disk space checks

Extract each CSAR member one by one, checking the available disk space before writing each member. Each member is fully extracted using zf.extract() before moving to the next one.

Checking before the first member as well as every later one means this loop also acts as the upfront check for the whole archive, and re-checking before each member catches space used by something else, like a concurrent upload, while extraction is still in progress.

tacker.common.csar_utils.load_csar_data(context, package_uuid, zip_path)