Refactor document scanning progress share variable initialization

This commit is contained in:
yangdx
2025-02-27 16:07:00 +08:00
parent e881bc0709
commit 92ecb0da97
2 changed files with 16 additions and 17 deletions

View File

@@ -267,8 +267,20 @@ class LightRAG:
_storages_status: StoragesStatus = field(default=StoragesStatus.NOT_CREATED)
def __post_init__(self):
from lightrag.kg.shared_storage import initialize_share_data
from lightrag.kg.shared_storage import initialize_share_data, try_initialize_namespace, get_namespace_data
initialize_share_data()
need_init = try_initialize_namespace("scan_progress")
scan_progress = get_namespace_data("scan_progress")
if need_init:
scan_progress.update(
{
"is_scanning": False,
"current_file": "",
"indexed_count": 0,
"total_files": 0,
"progress": 0,
}
)
os.makedirs(os.path.dirname(self.log_file_path), exist_ok=True)
set_logger(self.log_file_path, self.log_level)