Skip to content

Commit

Permalink
refactor: catch error for rar file
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Sep 1, 2023
1 parent df0000f commit 4a121a8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ckanext/unfold/adapters/rar.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
from __future__ import annotations

import logging

import rarfile
from rarfile import RarInfo
from rarfile import RarInfo, Error as RarError

import ckanext.unfold.utils as unf_utils
import ckanext.unfold.types as unf_types

log = logging.getLogger(__name__)


def build_directory_tree(filepath: str):
with rarfile.RarFile(filepath) as archive:
file_list: list[RarInfo] = archive.infolist()
try:
with rarfile.RarFile(filepath) as archive:
file_list: list[RarInfo] = archive.infolist()
except RarError as e:
log.error(f"Error openning rar archive: {e}")
return []

nodes: list[unf_types.Node] = []

Expand Down

0 comments on commit 4a121a8

Please sign in to comment.