diff --git a/tools/askcode_summary_index.py b/tools/askcode_summary_index.py index 6a03b02..093ad7e 100644 --- a/tools/askcode_summary_index.py +++ b/tools/askcode_summary_index.py @@ -7,6 +7,7 @@ from chat.ask_codebase.indexing.module_summary import SummaryWrapper # 为已经分析的文件记录最后修改时间 g_file_last_modified_saved = {} +g_file_need_index = {} def load_file_last_modified(filePath: str): if not os.path.exists(filePath): @@ -37,6 +38,7 @@ def is_file_modified(filePath: str, supportedFileTypes) -> bool: for part in relativePath.split(os.sep): if part.startswith('.'): + print("Not hidden file: ", filePath) return False fileLastModified = g_file_last_modified_saved.get(relativePath, 0) @@ -44,20 +46,25 @@ def is_file_modified(filePath: str, supportedFileTypes) -> bool: if fileLastModified != fileCurrentModified: g_file_last_modified_saved[relativePath] = fileCurrentModified - return True + return True + return False def custom_file_filter(file_path: str, supportedFileTypes) -> bool: - needIndex = simple_file_filter(file_path) - if not needIndex: - print("==> ", file_path, needIndex) - return needIndex + needIndex = False + file_path = os.path.abspath(file_path) + if file_path in g_file_need_index: + return g_file_need_index[file_path] + + # check size of true value in g_file_need_index > 100 + if sum(g_file_need_index.values()) > 100: + return False if os.path.isdir(file_path): needIndex = True else: needIndex = is_file_modified(file_path, supportedFileTypes) - print("==> ", file_path, needIndex) + g_file_need_index[file_path] = needIndex return needIndex