yangdx
commited on
Commit
·
989a2b6
1
Parent(s):
22483ea
fix: Improve file path handling and logging for document scanning
Browse files• Convert relative paths to absolute paths
• Add logging for file scanning progress
• Log total number of new files found
• Enhance file scanning feedback
• Improve path resolution safety
lightrag/api/lightrag_server.py
CHANGED
@@ -564,6 +564,10 @@ def parse_args() -> argparse.Namespace:
|
|
564 |
|
565 |
args = parser.parse_args()
|
566 |
|
|
|
|
|
|
|
|
|
567 |
ollama_server_infos.LIGHTRAG_MODEL = args.simulated_model_name
|
568 |
|
569 |
return args
|
@@ -595,6 +599,7 @@ class DocumentManager:
|
|
595 |
"""Scan input directory for new files"""
|
596 |
new_files = []
|
597 |
for ext in self.supported_extensions:
|
|
|
598 |
for file_path in self.input_dir.rglob(f"*{ext}"):
|
599 |
if file_path not in self.indexed_files:
|
600 |
new_files.append(file_path)
|
@@ -1198,6 +1203,7 @@ def create_app(args):
|
|
1198 |
new_files = doc_manager.scan_directory_for_new_files()
|
1199 |
scan_progress["total_files"] = len(new_files)
|
1200 |
|
|
|
1201 |
for file_path in new_files:
|
1202 |
try:
|
1203 |
with progress_lock:
|
|
|
564 |
|
565 |
args = parser.parse_args()
|
566 |
|
567 |
+
# conver relative path to absolute path
|
568 |
+
args.working_dir = os.path.abspath(args.working_dir)
|
569 |
+
args.input_dir = os.path.abspath(args.input_dir)
|
570 |
+
|
571 |
ollama_server_infos.LIGHTRAG_MODEL = args.simulated_model_name
|
572 |
|
573 |
return args
|
|
|
599 |
"""Scan input directory for new files"""
|
600 |
new_files = []
|
601 |
for ext in self.supported_extensions:
|
602 |
+
logger.info(f"Scanning for {ext} files in {self.input_dir}")
|
603 |
for file_path in self.input_dir.rglob(f"*{ext}"):
|
604 |
if file_path not in self.indexed_files:
|
605 |
new_files.append(file_path)
|
|
|
1203 |
new_files = doc_manager.scan_directory_for_new_files()
|
1204 |
scan_progress["total_files"] = len(new_files)
|
1205 |
|
1206 |
+
logger.info(f"Found {len(new_files)} new files to index.")
|
1207 |
for file_path in new_files:
|
1208 |
try:
|
1209 |
with progress_lock:
|