mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-28 06:22:33 +00:00
Merge pull request #32709 from silentoplayz/fix/prompt-save-unchanged-no-version
fix: saving a prompt without changes adds no version to its history
This commit is contained in:
parent
7484c75e16
commit
312d113fd0
1 changed files with 15 additions and 6 deletions
|
|
@ -434,11 +434,7 @@ class PromptsTable:
|
|||
current_access_grants = await self._get_access_grants(prompt.id, db=session)
|
||||
|
||||
# Check if content changed to decide on history creation
|
||||
content_changed = (
|
||||
prompt.name != form_data.name
|
||||
or prompt.content != form_data.content
|
||||
or form_data.access_grants is not None
|
||||
)
|
||||
content_changed = prompt.name != form_data.name or prompt.content != form_data.content
|
||||
|
||||
# Update prompt fields
|
||||
prompt.name = form_data.name
|
||||
|
|
@ -447,8 +443,15 @@ class PromptsTable:
|
|||
prompt.meta = form_data.meta or prompt.meta
|
||||
prompt.updated_at = int(time.time())
|
||||
if form_data.access_grants is not None:
|
||||
previous_access_grants = {
|
||||
(grant.principal_type, grant.principal_id, grant.permission) for grant in current_access_grants
|
||||
}
|
||||
await AccessGrants.set_access_grants('prompt', prompt.id, form_data.access_grants, db=session)
|
||||
current_access_grants = await self._get_access_grants(prompt.id, db=session)
|
||||
if previous_access_grants != {
|
||||
(grant.principal_type, grant.principal_id, grant.permission) for grant in current_access_grants
|
||||
}:
|
||||
content_changed = True
|
||||
|
||||
await session.commit()
|
||||
|
||||
|
|
@ -504,7 +507,6 @@ class PromptsTable:
|
|||
prompt.name != form_data.name
|
||||
or prompt.command != form_data.command
|
||||
or prompt.content != form_data.content
|
||||
or form_data.access_grants is not None
|
||||
or (form_data.tags is not None and prompt.tags != form_data.tags)
|
||||
)
|
||||
|
||||
|
|
@ -521,8 +523,15 @@ class PromptsTable:
|
|||
prompt.tags = form_data.tags
|
||||
|
||||
if form_data.access_grants is not None:
|
||||
previous_access_grants = {
|
||||
(grant.principal_type, grant.principal_id, grant.permission) for grant in current_access_grants
|
||||
}
|
||||
await AccessGrants.set_access_grants('prompt', prompt.id, form_data.access_grants, db=session)
|
||||
current_access_grants = await self._get_access_grants(prompt.id, db=session)
|
||||
if previous_access_grants != {
|
||||
(grant.principal_type, grant.principal_id, grant.permission) for grant in current_access_grants
|
||||
}:
|
||||
content_changed = True
|
||||
|
||||
prompt.updated_at = int(time.time())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue