mirror of https://github.com/jumpserver/jumpserver
fix(terminal): 修复正在使用的命令/录像存储可以被删除的问题
parent
da4f9efb42
commit
1915224063
|
@ -20,9 +20,12 @@ class BaseStorageViewSetMixin:
|
||||||
|
|
||||||
def destroy(self, request, *args, **kwargs):
|
def destroy(self, request, *args, **kwargs):
|
||||||
instance = self.get_object()
|
instance = self.get_object()
|
||||||
if not instance.can_delete():
|
if instance.in_defaults():
|
||||||
data = {'msg': _('Deleting the default storage is not allowed')}
|
data = {'msg': _('Deleting the default storage is not allowed')}
|
||||||
return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
|
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)
|
return super().destroy(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -405,8 +405,8 @@ class CommandStorage(CommonModelMixin):
|
||||||
storage = jms_storage.get_log_storage(self.config)
|
storage = jms_storage.get_log_storage(self.config)
|
||||||
return storage.ping()
|
return storage.ping()
|
||||||
|
|
||||||
def can_delete(self):
|
def is_using(self):
|
||||||
return not self.in_defaults()
|
return Terminal.objects.filter(command_storage=self.name).exists()
|
||||||
|
|
||||||
|
|
||||||
class ReplayStorage(CommonModelMixin):
|
class ReplayStorage(CommonModelMixin):
|
||||||
|
@ -458,5 +458,5 @@ class ReplayStorage(CommonModelMixin):
|
||||||
src = os.path.join(settings.BASE_DIR, 'common', target)
|
src = os.path.join(settings.BASE_DIR, 'common', target)
|
||||||
return storage.is_valid(src, target)
|
return storage.is_valid(src, target)
|
||||||
|
|
||||||
def can_delete(self):
|
def is_using(self):
|
||||||
return not self.in_defaults()
|
return Terminal.objects.filter(replay_storage=self.name).exists()
|
||||||
|
|
Loading…
Reference in New Issue