From 910c6973f35800289b33d0e54ad9896aa8a70676 Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 16 Jul 2025 20:35:24 +0800 Subject: [PATCH] Limit file deletion to current directory only after document cleaning --- lightrag/api/routers/document_routes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightrag/api/routers/document_routes.py b/lightrag/api/routers/document_routes.py index 288a66e1..68642909 100644 --- a/lightrag/api/routers/document_routes.py +++ b/lightrag/api/routers/document_routes.py @@ -1301,11 +1301,11 @@ def create_document_routes( "Starting to delete files in input directory" ) - # Delete all files in input_dir + # Delete only files in the current directory, preserve files in subdirectories deleted_files_count = 0 file_errors_count = 0 - for file_path in doc_manager.input_dir.glob("**/*"): + for file_path in doc_manager.input_dir.glob("*"): if file_path.is_file(): try: file_path.unlink()