perf: applet host platform

This commit is contained in:
ibuler
2024-07-02 15:13:51 +08:00
committed by 老广
parent 912cefbc85
commit d42acc3848
6 changed files with 15 additions and 5 deletions

View File

@@ -87,6 +87,8 @@ class DownloadUploadMixin:
path = os.path.join(settings.APPS_DIR, 'terminal', 'applets', instance.name)
else:
path = default_storage.path('applets/{}'.format(instance.name))
if not os.path.exists(path):
raise ValidationError({'error': _('Applet not found in path: {}').format(path)})
zip_path = shutil.make_archive(path, 'zip', path)
with open(zip_path, 'rb') as f:
response = HttpResponse(f.read(), status=200, content_type='application/octet-stream')