mirror of
https://github.com/val1813/kwcode.git
synced 2026-09-03 06:34:30 +08:00
fix: normalize file paths in DocReader cache for cross-platform compatibility
Resolves Windows test failure where short path format (RUNNER~1) didn't match long path format (runneradmin) in cache lookups. Also fixes macOS symlink issues (/var vs /private/var). Changes: - Use path.resolve() for cache keys in DocReader._read_file - Update test to use resolved paths for assertion Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -113,7 +113,7 @@ class DocReader:
|
||||
return result
|
||||
|
||||
def _read_file(self, path: Path) -> list[str]:
|
||||
key = str(path)
|
||||
key = str(path.resolve())
|
||||
if key in self._cache:
|
||||
return self._cache[key]
|
||||
|
||||
|
||||
@@ -349,13 +349,14 @@ Connection pooling is configured in src/db/pool.py.
|
||||
|
||||
def test_cache(self):
|
||||
from kaiwu.knowledge.doc_reader import DocReader
|
||||
from pathlib import Path
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
with open(os.path.join(d, "doc.md"), "w", encoding="utf-8") as f:
|
||||
f.write("This is a test document with enough content to be a paragraph.\n")
|
||||
reader = DocReader(d)
|
||||
reader.find_relevant("test")
|
||||
# Second call should use cache
|
||||
assert str(os.path.join(d, "doc.md")) in reader._cache
|
||||
# Second call should use cache (use resolved path for comparison)
|
||||
assert str(Path(d, "doc.md").resolve()) in reader._cache
|
||||
|
||||
|
||||
# ── PatternMd.count_similar_failures ───────────────────────
|
||||
|
||||
Reference in New Issue
Block a user