Skip to content

Commit

Permalink
调整 - 减少不必要的状态检查任务 (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
neavo authored Nov 3, 2024
1 parent 47ac969 commit 9cedb07
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Module_Folders/Translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,21 @@ def translation_manual_export(self, event: int, data: dict):

# 翻译状态检查事件
def translation_continue_check(self, event: int, data: dict):
# 只有当翻译状态为 无任务 时才检查 继续翻译状态,其他情况直接返回 False
if not hasattr(self, "configurator") or self.configurator.status != Base.STATUS.IDLE:
self.emit(Base.EVENT.TRANSLATION_CONTINUE_CHECK_DONE, {
"translation_continue" : False,
})
return

# 开始检查 继续翻译状态
translation_continue = False
try:
config = self.load_config()

# 避免读取缓存时锁定文件从而影响缓存写入的任务
with self.cache_file_lock:
cache = self.load_cache_file(f"{self.load_config().get("label_output_path", "")}/cache/AinieeCacheData.json")
cache = self.load_cache_file(f"{config.get("label_output_path", "")}/cache/AinieeCacheData.json")

translated_line = [v for v in cache if v.get("translation_status", -1) == 1]
untranslated_line = [v for v in cache if v.get("translation_status", -1) in (0, 2)]
Expand Down

0 comments on commit 9cedb07

Please sign in to comment.