fix renaming exports with a slash (#16588)

This commit is contained in:
Josh Hawkins 2025-02-14 20:18:14 -06:00 committed by GitHub
parent 7b3556e4ad
commit 6bb1a5dfd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 5 deletions

View File

@ -0,0 +1,5 @@
from pydantic import BaseModel, Field
class ExportRenameBody(BaseModel):
name: str = Field(title="Friendly name", max_length=256)

View File

@ -12,6 +12,7 @@ from peewee import DoesNotExist
from playhouse.shortcuts import model_to_dict
from frigate.api.defs.request.export_recordings_body import ExportRecordingsBody
from frigate.api.defs.request.export_rename_body import ExportRenameBody
from frigate.api.defs.tags import Tags
from frigate.const import EXPORT_DIR
from frigate.models import Export, Previews, Recordings
@ -129,8 +130,8 @@ def export_recording(
)
@router.patch("/export/{event_id}/{new_name}")
def export_rename(event_id: str, new_name: str):
@router.patch("/export/{event_id}/rename")
def export_rename(event_id: str, body: ExportRenameBody):
try:
export: Export = Export.get(Export.id == event_id)
except DoesNotExist:
@ -144,7 +145,7 @@ def export_rename(event_id: str, new_name: str):
status_code=404,
)
export.name = new_name
export.name = body.name
export.save()
return JSONResponse(
content=(

View File

@ -83,9 +83,11 @@ function Exports() {
const onHandleRename = useCallback(
(id: string, update: string) => {
axios
.patch(`export/${id}/${encodeURIComponent(update)}`)
.patch(`export/${id}/rename`, {
name: update,
})
.then((response) => {
if (response.status == 200) {
if (response.status === 200) {
setDeleteClip(undefined);
mutate();
}