mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-05-03 09:43:55 +00:00
perf: settings refresh_item
This commit is contained in:
@@ -6,7 +6,7 @@ from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
from django.core.files.storage import default_storage
|
||||
from django.core.files.uploadedfile import InMemoryUploadedFile
|
||||
from django.db import models, connections
|
||||
from django.db import models, connections, transaction
|
||||
from django.db.utils import ProgrammingError, OperationalError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from rest_framework.utils.encoders import JSONEncoder
|
||||
@@ -86,7 +86,8 @@ class Setting(models.Model):
|
||||
|
||||
@classmethod
|
||||
def refresh_item(cls, name):
|
||||
item = cls.objects.filter(name=name).first()
|
||||
with transaction.atomic():
|
||||
item = cls.objects.select_for_update().filter(name=name).first()
|
||||
if not item:
|
||||
return
|
||||
item.refresh_setting()
|
||||
|
||||
Reference in New Issue
Block a user