Skip to content

Commit eb76450

Browse files
authored
fix: Exporting zip cannot open the file (#1939)
1 parent 7f0547a commit eb76450

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

apps/dataset/serializers/common_serializers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def write_image(zip_path: str, image_list: List[str]):
4747
if text.startswith('(/api/file/'):
4848
r = text.replace('(/api/file/', '').replace(')', '')
4949
file = QuerySet(File).filter(id=r).first()
50+
if file is None:
51+
break
5052
zip_inner_path = os.path.join('api', 'file', r)
5153
file_path = os.path.join(zip_path, zip_inner_path)
5254
if not os.path.exists(os.path.dirname(file_path)):
@@ -56,6 +58,8 @@ def write_image(zip_path: str, image_list: List[str]):
5658
else:
5759
r = text.replace('(/api/image/', '').replace(')', '')
5860
image_model = QuerySet(Image).filter(id=r).first()
61+
if image_model is None:
62+
break
5963
zip_inner_path = os.path.join('api', 'image', r)
6064
file_path = os.path.join(zip_path, zip_inner_path)
6165
if not os.path.exists(os.path.dirname(file_path)):

0 commit comments

Comments
 (0)