mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-18 17:14:26 +03:00
Fix rename operation 2
This commit is contained in:
parent
ff55faf5bd
commit
0ccf512b35
@ -117,10 +117,19 @@ def deregister_faces(request: Request, name: str, body: dict = None):
|
|||||||
status_code=404,
|
status_code=404,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
face_dir = os.path.join(FACE_DIR, name)
|
||||||
|
|
||||||
context: EmbeddingsContext = request.app.embeddings
|
context: EmbeddingsContext = request.app.embeddings
|
||||||
context.delete_face_ids(
|
context.delete_face_ids(
|
||||||
name, map(lambda file: sanitize_filename(file), list_of_ids)
|
name, map(lambda file: sanitize_filename(file), list_of_ids)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if os.path.exists(face_dir) and not os.listdir(face_dir):
|
||||||
|
os.rmdir(face_dir)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to remove directory {face_dir}: {str(e)}")
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=({"success": True, "message": "Successfully deleted faces."}),
|
content=({"success": True, "message": "Successfully deleted faces."}),
|
||||||
status_code=200,
|
status_code=200,
|
||||||
|
|||||||
@ -172,8 +172,13 @@ export default function FaceLibrary() {
|
|||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', blob, image);
|
formData.append('file', new File([blob], image));
|
||||||
await axios.post(`/faces/${renameData.newName}`, formData);
|
|
||||||
|
await axios.post(`/faces/${renameData.newName}`, formData, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldFaceImages.length > 0) {
|
if (oldFaceImages.length > 0) {
|
||||||
@ -182,7 +187,7 @@ export default function FaceLibrary() {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await axios.post(`/faces/${renameData.oldName}/delete`, {
|
await axios.post(`/faces/${renameData.oldName}/delete`, {
|
||||||
ids: ['dummy'] // Send a dummy ID to pass validation
|
ids: ['dummy']
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user