diff --git a/docs/backend/backend_python/openapi.json b/docs/backend/backend_python/openapi.json index 4ab3ffa44..ad1b7cdc8 100644 --- a/docs/backend/backend_python/openapi.json +++ b/docs/backend/backend_python/openapi.json @@ -2073,119 +2073,6 @@ ], "title": "DeleteFoldersResponse" }, - "app__schemas__folders__ErrorResponse": { - "properties": { - "success": { - "type": "boolean", - "title": "Success", - "default": false - }, - "message": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Message" - }, - "error": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Error" - } - }, - "type": "object", - "title": "ErrorResponse" - }, - "app__schemas__face_clusters__ErrorResponse": { - "properties": { - "success": { - "type": "boolean", - "title": "Success", - "default": false - }, - "message": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Message" - }, - "error": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Error" - } - }, - "type": "object", - "title": "ErrorResponse" - }, - "app__schemas__images__ErrorResponse": { - "properties": { - "success": { - "type": "boolean", - "title": "Success", - "default": false - }, - "message": { - "type": "string", - "title": "Message" - }, - "error": { - "type": "string", - "title": "Error" - } - }, - "type": "object", - "required": [ - "message", - "error" - ], - "title": "ErrorResponse" - }, - "app__schemas__user_preferences__ErrorResponse": { - "properties": { - "success": { - "type": "boolean", - "title": "Success" - }, - "error": { - "type": "string", - "title": "Error" - }, - "message": { - "type": "string", - "title": "Message" - } - }, - "type": "object", - "required": [ - "success", - "error", - "message" - ], - "title": "ErrorResponse", - "description": "Error response model" - }, "FaceSearchRequest": { "properties": { "path": { @@ -3407,6 +3294,119 @@ "type" ], "title": "ValidationError" + }, + "app__schemas__face_clusters__ErrorResponse": { + "properties": { + "success": { + "type": "boolean", + "title": "Success", + "default": false + }, + "message": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Message" + }, + "error": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Error" + } + }, + "type": "object", + "title": "ErrorResponse" + }, + "app__schemas__folders__ErrorResponse": { + "properties": { + "success": { + "type": "boolean", + "title": "Success", + "default": false + }, + "message": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Message" + }, + "error": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Error" + } + }, + "type": "object", + "title": "ErrorResponse" + }, + "app__schemas__images__ErrorResponse": { + "properties": { + "success": { + "type": "boolean", + "title": "Success", + "default": false + }, + "message": { + "type": "string", + "title": "Message" + }, + "error": { + "type": "string", + "title": "Error" + } + }, + "type": "object", + "required": [ + "message", + "error" + ], + "title": "ErrorResponse" + }, + "app__schemas__user_preferences__ErrorResponse": { + "properties": { + "success": { + "type": "boolean", + "title": "Success" + }, + "error": { + "type": "string", + "title": "Error" + }, + "message": { + "type": "string", + "title": "Message" + } + }, + "type": "object", + "required": [ + "success", + "error", + "message" + ], + "title": "ErrorResponse", + "description": "Error response model" } } } diff --git a/sync-microservice/app/utils/watcher.py b/sync-microservice/app/utils/watcher.py index 902a50cf5..1cd9c302e 100644 --- a/sync-microservice/app/utils/watcher.py +++ b/sync-microservice/app/utils/watcher.py @@ -311,13 +311,16 @@ def watcher_util_stop_folder_watcher() -> None: # Signal the watcher to stop stop_event.set() - # Wait for thread to finish - watcher_thread.join(timeout=5.0) + # Wait for thread to finish if not called from the thread itself + if threading.current_thread() != watcher_thread: + watcher_thread.join(timeout=5.0) - if watcher_thread.is_alive(): - logger.warning("Warning: Watcher thread did not stop gracefully") + if watcher_thread.is_alive(): + logger.warning("Warning: Watcher thread did not stop gracefully") + else: + logger.info("Watcher stopped successfully") else: - logger.info("Watcher stopped successfully") + logger.info("Watcher stopped successfully (called from within watcher thread)") except Exception as e: logger.error(f"Error stopping watcher: {e}") @@ -336,6 +339,17 @@ def watcher_util_restart_folder_watcher() -> bool: True if restart was successful, False otherwise """ logger.info("Restarting folder watcher...") + + if watcher_thread and threading.current_thread() == watcher_thread: + # We are inside the watcher thread, so we can't join ourselves. + # Launch a background thread to do the restart. + def restart_worker(): + watcher_util_stop_folder_watcher() + watcher_util_start_folder_watcher() + + threading.Thread(target=restart_worker, daemon=True).start() + return True + watcher_util_stop_folder_watcher() return watcher_util_start_folder_watcher()