mirror of https://github.com/sbt/sbt.git
[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:
parent
28f7957307
commit
4ed22747dc
|
|
@ -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) =>
|
||||
|
|
|
|||
Loading…
Reference in New Issue