优化一些程序

This commit is contained in:
2026-04-24 15:02:36 +08:00
parent 7f61a585be
commit ecf8f8b084
5 changed files with 998 additions and 11 deletions

View File

@@ -19,7 +19,7 @@ import requests
import math
OLLAMA_EMBED_URL = os.environ.get('OLLAMA_EMBED_URL', 'http://localhost:11434/api/embeddings')
OLLAMA_EMBED_MODEL = os.environ.get('OLLAMA_EMBED_MODEL', 'nomic/text-embedding-3-large')
OLLAMA_EMBED_MODEL = os.environ.get('OLLAMA_EMBED_MODEL', 'nomic-embed-text:latest')
def clear_directory(dir_path: Path) -> None:
@@ -93,6 +93,7 @@ def find_best_match(title: str, candidates: List[Tuple[Path, datetime]]) -> Tupl
stem_norm = normalize_for_match(file_path.stem)
if stem_norm and (stem_norm == title_norm or stem_norm in title_norm or title_norm in stem_norm):
exact_candidates.append((file_path, ctime, stem_norm))
break
if exact_candidates:
# 直接返回最精确的“包含匹配”候选项
@@ -548,8 +549,8 @@ def build_file_associations(
latest_extracted = max(extracted_times)
# 如果压缩文件时间和解压文件最晚时间差小于 30 秒,返回 None
if archive_mtime is not None and abs(latest_extracted - archive_mtime) < 300:
# 如果压缩文件时间和解压文件最晚时间差小于 8000 秒,返回 None
if archive_mtime is not None and abs(latest_extracted - archive_mtime) < 18000:
return None
return latest_extracted