mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-18 17:14:26 +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:
|
||||
if os.path.exists(face_dir) and not os.listdir(face_dir):
|
||||
os.rmdir(face_dir)
|
||||
if os.path.exists(face_dir):
|
||||
shutil.rmtree(face_dir)
|
||||
except Exception as 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(
|
||||
content=({"success": True, "message": "Successfully deleted faces."}),
|
||||
|
||||
@ -6,6 +6,7 @@ import logging
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import shutil
|
||||
from typing import Optional
|
||||
|
||||
import cv2
|
||||
@ -448,8 +449,8 @@ class FaceProcessor(RealTimeProcessorApi):
|
||||
"success": False,
|
||||
}
|
||||
|
||||
# Rename the directory
|
||||
os.rename(old_folder, new_folder)
|
||||
shutil.copytree(old_folder, new_folder)
|
||||
shutil.rmtree(old_folder)
|
||||
|
||||
# Clear and rebuild classifier with new names
|
||||
self.__clear_classifier()
|
||||
|
||||
@ -210,7 +210,8 @@ export default function FaceLibrary() {
|
||||
ids: images.length ? images : ['dummy']
|
||||
});
|
||||
setRenameDialog(false);
|
||||
await refreshFaces(); // Wait for refresh
|
||||
setPageToggle(faces[0]);
|
||||
await refreshFaces();
|
||||
toast.success("Successfully deleted face", { position: "top-center" });
|
||||
} catch (error) {
|
||||
const axiosError = error as AxiosError<{ message: string }>;
|
||||
@ -219,7 +220,7 @@ export default function FaceLibrary() {
|
||||
{ position: "top-center" }
|
||||
);
|
||||
}
|
||||
}, [renameData.oldName, faceData, refreshFaces]);
|
||||
}, [renameData.oldName, faceData, refreshFaces, faces, setPageToggle]);
|
||||
|
||||
if (!config) {
|
||||
return <ActivityIndicator />;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user