mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-09 19:29:48 +00:00
fix: except 无法解压的文件包 (#9677)
Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
This commit is contained in:
@@ -6,6 +6,7 @@ from django.conf import settings
|
||||
from django.shortcuts import get_object_or_404
|
||||
from rest_framework import status
|
||||
|
||||
from common.exceptions import JMSException
|
||||
from orgs.mixins.api import OrgBulkModelViewSet
|
||||
from ..exception import PlaybookNoValidEntry
|
||||
from ..models import Playbook
|
||||
@@ -39,7 +40,11 @@ class PlaybookViewSet(OrgBulkModelViewSet):
|
||||
if 'multipart/form-data' in self.request.headers['Content-Type']:
|
||||
src_path = os.path.join(settings.MEDIA_ROOT, instance.path.name)
|
||||
dest_path = os.path.join(settings.DATA_DIR, "ops", "playbook", instance.id.__str__())
|
||||
try:
|
||||
unzip_playbook(src_path, dest_path)
|
||||
except RuntimeError as e:
|
||||
raise JMSException(code='invalid_playbook_file', detail={"msg": "Unzip failed"})
|
||||
|
||||
if 'main.yml' not in os.listdir(dest_path):
|
||||
raise PlaybookNoValidEntry
|
||||
|
||||
|
Reference in New Issue
Block a user