fix: applet 压缩包名字(1).zip时 上传失败} (#12397)

Co-authored-by: feng <1304903146@qq.com>
pull/12400/head
fit2bot 2023-12-21 15:42:09 +08:00 committed by GitHub
parent dc56b019b1
commit bc668f3e9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -1,4 +1,6 @@
import os
import os.path
import re
import shutil
import zipfile
from typing import Callable
@ -51,6 +53,11 @@ class DownloadUploadMixin:
raise ValidationError({'error': _('Invalid zip file') + ': {}'.format(e)})
tmp_dir = os.path.join(extract_to, file.name.replace('.zip', ''))
if not os.path.exists(tmp_dir):
name = file.name
name = re.match(r"(\w+)", name).group()
tmp_dir = os.path.join(extract_to, name)
manifest = Applet.validate_pkg(tmp_dir)
return manifest, tmp_dir