Skip to content

Commit

Permalink
perf: Change secret update version
Browse files Browse the repository at this point in the history
  • Loading branch information
feng626 authored and ibuler committed Dec 5, 2024
1 parent d8dfaf0 commit ff0f9eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/accounts/automations/change_secret/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def on_host_success(self, host, result):
if not account:
print("Account not found, deleted ?")
return

version_update_required = account.secret != recorder.new_secret
account.secret = recorder.new_secret
account.date_updated = timezone.now()

Expand All @@ -180,7 +182,10 @@ def on_host_success(self, host, result):
while retry_count < max_retries:
try:
recorder.save()
account.save(update_fields=['secret', 'date_updated'])
account_update_fields = ['secret', 'date_updated']
if version_update_required:
account_update_fields.append('version')
account.save(update_fields=account_update_fields)
break
except Exception as e:
retry_count += 1
Expand Down

0 comments on commit ff0f9eb

Please sign in to comment.