Read uploaded ZIPs consistently across Python versions

This commit is contained in:
2026-09-19 15:39:51 +03:30
parent a9401b6251
commit 86edf97c50
+2 -1
View File
@@ -189,7 +189,8 @@ def create_app(data_dir=None, token=None):
if photos or len(archives) != 1: if photos or len(archives) != 1:
abort(400, "Send either photos or one ZIP archive, not both") abort(400, "Send either photos or one ZIP archive, not both")
try: try:
with zipfile.ZipFile(archives[0].stream) as archive: # Python 3.10's SpooledTemporaryFile lacks ZipFile's seekable API.
with zipfile.ZipFile(io.BytesIO(archives[0].read())) as archive:
members = [item for item in archive.infolist() if not item.is_dir() members = [item for item in archive.infolist() if not item.is_dir()
and not item.filename.startswith("__MACOSX/") and not item.filename.startswith("__MACOSX/")
and Path(item.filename).name != ".DS_Store"] and Path(item.filename).name != ".DS_Store"]