Avoid rewriting warm extraction cache
This commit is contained in:
parent
4a8980110d
commit
9fcafc290c
2 changed files with 21 additions and 18 deletions
|
|
@ -483,14 +483,7 @@ class AdapterProject:
|
|||
if source.source_id in invalidated:
|
||||
contribution = loader.extract_source(source)
|
||||
reparsed.append(source.source_id)
|
||||
else:
|
||||
record = cached[source.source_id]
|
||||
contribution = source_projection(record.payload)
|
||||
hits.append(source.source_id)
|
||||
validate_source_projection(source, contribution)
|
||||
contributions.append(contribution)
|
||||
cache_records.append(
|
||||
CachedSource(
|
||||
cache_record = CachedSource(
|
||||
source_id=source.source_id,
|
||||
source_path=source.source_path,
|
||||
fingerprint=source.fingerprint,
|
||||
|
|
@ -498,7 +491,13 @@ class AdapterProject:
|
|||
dependencies=source.dependencies,
|
||||
payload=source_payload(contribution),
|
||||
)
|
||||
)
|
||||
else:
|
||||
cache_record = cached[source.source_id]
|
||||
contribution = source_projection(cache_record.payload)
|
||||
hits.append(source.source_id)
|
||||
validate_source_projection(source, contribution)
|
||||
contributions.append(contribution)
|
||||
cache_records.append(cache_record)
|
||||
projection = AdapterProjection(
|
||||
project_id=manifest.project_id,
|
||||
title=manifest.title,
|
||||
|
|
@ -542,6 +541,7 @@ class AdapterProject:
|
|||
raise DocForgeError(
|
||||
"source_changed", "Adapter sources changed during incremental extraction"
|
||||
)
|
||||
if cache is None or invalidated or deleted:
|
||||
write_extraction_cache(
|
||||
self._cache_path,
|
||||
ExtractionCache(
|
||||
|
|
|
|||
|
|
@ -303,11 +303,14 @@ class AdapterContractTests(unittest.TestCase):
|
|||
self.assertEqual(2, first["build"]["reparsed_sources"])
|
||||
self.assertEqual(0, first["build"]["cache_hits"])
|
||||
loader.extract_calls.clear()
|
||||
cache_path = root / ".cache" / "incremental" / "extractions.json"
|
||||
cache_modified = cache_path.stat().st_mtime_ns
|
||||
|
||||
second = index.build()
|
||||
self.assertEqual([], loader.extract_calls)
|
||||
self.assertEqual(0, second["build"]["reparsed_sources"])
|
||||
self.assertEqual(2, second["build"]["cache_hits"])
|
||||
self.assertEqual(cache_modified, cache_path.stat().st_mtime_ns)
|
||||
|
||||
loader.sources["guide.foundation"] = "Changed foundation."
|
||||
loader.extract_calls.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue