mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-19 09:27:06 +03:00
Fix renaming operation
This commit is contained in:
parent
639d2bdea7
commit
39fbd8a76f
@ -125,10 +125,14 @@ def deregister_faces(request: Request, name: str, body: dict = None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.path.exists(face_dir) and not os.listdir(face_dir):
|
if os.path.exists(face_dir):
|
||||||
os.rmdir(face_dir)
|
shutil.rmtree(face_dir)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to remove directory {face_dir}: {str(e)}")
|
logger.error(f"Failed to remove directory {face_dir}: {str(e)}")
|
||||||
|
return JSONResponse(
|
||||||
|
content=({"success": False, "message": f"Failed to remove directory: {str(e)}"}),
|
||||||
|
status_code=500,
|
||||||
|
)
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=({"success": True, "message": "Successfully deleted faces."}),
|
content=({"success": True, "message": "Successfully deleted faces."}),
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
import shutil
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
@ -448,8 +449,8 @@ class FaceProcessor(RealTimeProcessorApi):
|
|||||||
"success": False,
|
"success": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rename the directory
|
shutil.copytree(old_folder, new_folder)
|
||||||
os.rename(old_folder, new_folder)
|
shutil.rmtree(old_folder)
|
||||||
|
|
||||||
# Clear and rebuild classifier with new names
|
# Clear and rebuild classifier with new names
|
||||||
self.__clear_classifier()
|
self.__clear_classifier()
|
||||||
|
|||||||
@ -210,7 +210,8 @@ export default function FaceLibrary() {
|
|||||||
ids: images.length ? images : ['dummy']
|
ids: images.length ? images : ['dummy']
|
||||||
});
|
});
|
||||||
setRenameDialog(false);
|
setRenameDialog(false);
|
||||||
await refreshFaces(); // Wait for refresh
|
setPageToggle(faces[0]);
|
||||||
|
await refreshFaces();
|
||||||
toast.success("Successfully deleted face", { position: "top-center" });
|
toast.success("Successfully deleted face", { position: "top-center" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const axiosError = error as AxiosError<{ message: string }>;
|
const axiosError = error as AxiosError<{ message: string }>;
|
||||||
@ -219,7 +220,7 @@ export default function FaceLibrary() {
|
|||||||
{ position: "top-center" }
|
{ position: "top-center" }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [renameData.oldName, faceData, refreshFaces]);
|
}, [renameData.oldName, faceData, refreshFaces, faces, setPageToggle]);
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return <ActivityIndicator />;
|
return <ActivityIndicator />;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user