fix: Exporting zip cannot open the file (#1939)

This commit is contained in:
shaohuzhang1 2024-12-30 10:51:08 +08:00 committed by GitHub
parent 7f0547a8b8
commit eb76450cdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,6 +47,8 @@ def write_image(zip_path: str, image_list: List[str]):
if text.startswith('(/api/file/'):
r = text.replace('(/api/file/', '').replace(')', '')
file = QuerySet(File).filter(id=r).first()
if file is None:
break
zip_inner_path = os.path.join('api', 'file', r)
file_path = os.path.join(zip_path, zip_inner_path)
if not os.path.exists(os.path.dirname(file_path)):
@ -56,6 +58,8 @@ def write_image(zip_path: str, image_list: List[str]):
else:
r = text.replace('(/api/image/', '').replace(')', '')
image_model = QuerySet(Image).filter(id=r).first()
if image_model is None:
break
zip_inner_path = os.path.join('api', 'image', r)
file_path = os.path.join(zip_path, zip_inner_path)
if not os.path.exists(os.path.dirname(file_path)):