[2.x] fix: Check cache file exists before reading in Eval (#8513)

Fixes #8511

When loading a cached build definition, the code checked if the .class
file exists but not the .cache file. If the .cache file was missing
(deleted, corrupted, or from a partial compilation), it threw
NoSuchFileException.

Now both files are checked before using the cache. If either is missing,
the build definition is recompiled.
This commit is contained in:
MkDev11 2026-01-13 11:31:43 -05:00 committed by GitHub
parent 28f7957307
commit 4ed22747dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -225,7 +225,8 @@ class Eval(
val (extra, loader) =
try
backingDir match
case Some(backing) if classExists(backing, moduleName) =>
case Some(backing)
if classExists(backing, moduleName) && cacheExists(backing, moduleName) =>
val loader = (parent: ClassLoader) =>
(new URLClassLoader(Array(backing.toUri.toURL), parent): ClassLoader)
val extra = ev.read(cacheFile(backing, moduleName))
@ -273,6 +274,9 @@ class Eval(
private def classExists(dir: Path, name: String): Boolean =
Files.exists(dir.resolve(s"$name.class"))
private def cacheExists(dir: Path, name: String): Boolean =
Files.exists(cacheFile(dir, name))
private def getGeneratedFiles(moduleName: String): Seq[Path] =
backingDir match
case Some(dir) =>