mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-22 00:09:14 +00:00
fix(terminal): 修复正在使用的命令/录像存储可以被删除的问题
This commit is contained in:
@@ -20,9 +20,12 @@ class BaseStorageViewSetMixin:
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
instance = self.get_object()
|
||||
if not instance.can_delete():
|
||||
if instance.in_defaults():
|
||||
data = {'msg': _('Deleting the default storage is not allowed')}
|
||||
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
|
||||
if instance.is_using():
|
||||
data = {'msg': _('Cannot delete storage that is being used')}
|
||||
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
|
||||
return super().destroy(request, *args, **kwargs)
|
||||
|
||||
|
||||
|
@@ -405,8 +405,8 @@ class CommandStorage(CommonModelMixin):
|
||||
storage = jms_storage.get_log_storage(self.config)
|
||||
return storage.ping()
|
||||
|
||||
def can_delete(self):
|
||||
return not self.in_defaults()
|
||||
def is_using(self):
|
||||
return Terminal.objects.filter(command_storage=self.name).exists()
|
||||
|
||||
|
||||
class ReplayStorage(CommonModelMixin):
|
||||
@@ -458,5 +458,5 @@ class ReplayStorage(CommonModelMixin):
|
||||
src = os.path.join(settings.BASE_DIR, 'common', target)
|
||||
return storage.is_valid(src, target)
|
||||
|
||||
def can_delete(self):
|
||||
return not self.in_defaults()
|
||||
def is_using(self):
|
||||
return Terminal.objects.filter(replay_storage=self.name).exists()
|
||||
|
Reference in New Issue
Block a user