Skip to content

Commit

Permalink
issue: 4207369: EOFError while extracting logs (#288)
Browse files Browse the repository at this point in the history
* handle error

* fix comments, pylint and ruff

* fix comments, pylint and ruff

* fix comments, pylint and ruff
  • Loading branch information
Miryam-Schwartz authored Dec 19, 2024
1 parent d2768c0 commit 5d7ca22
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def _get_files_from_tar(
failed_extract = set()
folders_to_remove = set()
single_log_name, logs_with_dirs = self._split_based_on_dir(files_to_extract)

for member in opened_file:
base_name = os.path.basename(member.name)
full_dir_path = os.path.dirname(member.name)
Expand Down Expand Up @@ -128,17 +129,25 @@ def extract_files(
inner_file_open_mode = (
"r:gz" if self.is_gzip_file_obj(inner_tar_stream) else "r:"
)
with tarfile.open(
fileobj=inner_tar_stream, mode=inner_file_open_mode
) as inner_tar:
extracted_files, failed_files = self._get_files_from_tar(
inner_tar,
files_to_extract,
directories_to_extract,
destination,

try:
with tarfile.open(
fileobj=inner_tar_stream, mode=inner_file_open_mode
) as inner_tar:
extracted_files, failed_files = self._get_files_from_tar(
inner_tar,
files_to_extract,
directories_to_extract,
destination,
)
if len(extracted_files) > 0:
return extracted_files, failed_files

except EOFError as e:
log.LOGGER.info(
"EOFError in inner tar %s: %s", inner_tar_name, e
)
if len(extracted_files) > 0:
return extracted_files, failed_files
continue
# If we got to this point, we might have a simple tar, try to extract from it
return self._get_files_from_tar(
outer_tar, files_to_extract, directories_to_extract, destination
Expand Down

0 comments on commit 5d7ca22

Please sign in to comment.