Skip to content

Commit 85e7d51

Browse files
committed
fix: display preview error for ZIP files
1 parent f18b106 commit 85e7d51

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

invenio_app_rdm/records_ui/previewer/previewable_zip.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,17 @@ def can_preview(file):
120120

121121
def preview(file):
122122
"""Return the appropriate template and pass the file and an embed flag."""
123-
tree_raw = current_rdm_records_service.files.list_container(
124-
system_identity, file.record["id"], file.filename
125-
).to_dict()
123+
error=None
124+
try:
125+
tree_raw = current_rdm_records_service.files.list_container(
126+
system_identity, file.record["id"], file.filename
127+
).to_dict()
128+
except Exception as e:
129+
error = e
130+
tree_raw = {
131+
"entries": [],
132+
"directories": [],
133+
}
126134

127135
converted_tree = convert_zip_list_container(
128136
tree_raw["entries"], tree_raw["directories"], file.record["id"], file.filename
@@ -133,7 +141,7 @@ def preview(file):
133141
file=file,
134142
tree=tree_list,
135143
limit_reached=False,
136-
error=None,
144+
error=error,
137145
js_bundles=current_previewer.js_bundles + ["previewable-zip.js"],
138146
css_bundles=current_previewer.css_bundles + ["zip_css.css"],
139147
)

0 commit comments

Comments
 (0)