diff --git a/seasearch/index_store/index_manager.py b/seasearch/index_store/index_manager.py index 3923dec..336fceb 100644 --- a/seasearch/index_store/index_manager.py +++ b/seasearch/index_store/index_manager.py @@ -58,9 +58,9 @@ def update_library_filename_index(self, repo_id, commit_id, repo_filename_index, commit_id = to_commit time.sleep(1) - repo_status_filename_index.begin_update_repo(repo_id, commit_id, new_commit_id, metadata_last_updated_time) + repo_status_filename_index.begin_update_repo(repo_id, commit_id, new_commit_id, metadata_updated_time=metadata_last_updated_time) repo_filename_index.update(index_name, repo_id, commit_id, new_commit_id, rows, self.metadata_server_api, need_index_metadata) - repo_status_filename_index.finish_update_repo(repo_id, new_commit_id, metadata_query_time) + repo_status_filename_index.finish_update_repo(repo_id, new_commit_id, metadata_updated_time=metadata_query_time) logger.info('repo: %s, update repo filename index success', repo_id) diff --git a/seasearch/index_store/repo_status_index.py b/seasearch/index_store/repo_status_index.py index 22d70d3..5fbe464 100644 --- a/seasearch/index_store/repo_status_index.py +++ b/seasearch/index_store/repo_status_index.py @@ -6,8 +6,8 @@ def __init__(self, repo_id, from_commit, to_commit, **kwargs): self.repo_id = repo_id self.from_commit = from_commit self.to_commit = to_commit - if metadata_updated_time := kwargs.get('metadata_updated_time'): - self.metadata_updated_time = metadata_updated_time + if 'metadata_updated_time' in kwargs: + self.metadata_updated_time = kwargs['metadata_updated_time'] def need_recovery(self): return self.to_commit is not None @@ -71,8 +71,8 @@ def add_repo_status(self, repo_id, commit_id, updatingto, **kwargs): 'updatingto': updatingto, } - if metadata_updated_time := kwargs.get('metadata_updated_time'): - data.update(metadata_updated_time=metadata_updated_time) + if 'metadata_updated_time' in kwargs: + data.update(metadata_updated_time=kwargs['metadata_updated_time']) doc_id = repo_id self.seasearch_api.create_document_by_id(self.index_name, doc_id, data) @@ -89,14 +89,18 @@ def delete_documents_by_repo(self, repo_id): def get_repo_status_by_id(self, repo_id): doc = self.seasearch_api.get_document_by_id(self.index_name, repo_id) if doc.get('error'): - return RepoStatus(repo_id, None, None, None) + if self.is_status_filename_index(): + return RepoStatus(repo_id, None, None, metadata_updated_time=None) + else: + return RepoStatus(repo_id, None, None) + commit_id = doc['_source']['commit_id'] updatingto = doc['_source']['updatingto'] repo_id = doc['_source']['repo_id'] if self.is_status_filename_index(): metadata_updated_time = doc['_source']['metadata_updated_time'] - return RepoStatus(repo_id, commit_id, updatingto, metadata_updated_time) + return RepoStatus(repo_id, commit_id, updatingto, metadata_updated_time=metadata_updated_time) return RepoStatus(repo_id, commit_id, updatingto) @@ -171,8 +175,8 @@ def _repo_head_search(self, query_params): 'commit_id': commit_id, 'updatingto': updatingto, } - if metadata_updated_time := hit.get('_source').get('metadata_updated_time'): - repo_head['metadata_updated_time'] = metadata_updated_time + if 'metadata_updated_time' in hit.get('_source', {}): + repo_head['metadata_updated_time'] = hit.get('_source').get('metadata_updated_time') repo_heads.append(repo_head) return repo_heads, total diff --git a/seasearch/script/update.lock b/seasearch/script/update.lock new file mode 100644 index 0000000..e69de29