mirror of https://github.com/sbt/sbt.git
[2.x] fix: Workaround for NoSuchFileException
**Problem** In some scripted tests, we've seen NoSuchFileException. **Solution** Catch the exceptions related to caching.
This commit is contained in:
parent
65605efc8b
commit
7d76f8f33e
|
|
@ -254,22 +254,28 @@ class DiskActionCacheStore(base: Path, converter: FileConverter) extends Abstrac
|
||||||
|
|
||||||
private def getBlobs(refs: Seq[HashedVirtualFileRef]): Seq[VirtualFile] =
|
private def getBlobs(refs: Seq[HashedVirtualFileRef]): Seq[VirtualFile] =
|
||||||
refs.flatMap: r =>
|
refs.flatMap: r =>
|
||||||
val casFile = toCasFile(Digest(r))
|
try
|
||||||
if casFile.toFile().exists then
|
val casFile = toCasFile(Digest(r))
|
||||||
r match
|
if casFile.toFile().exists then
|
||||||
case p: PathBasedFile => Some(p)
|
r match
|
||||||
case _ =>
|
case p: PathBasedFile => Some(p)
|
||||||
val content = IO.read(casFile.toFile())
|
case _ =>
|
||||||
Some(StringVirtualFile1(r.id, content))
|
val content = IO.read(casFile.toFile())
|
||||||
else None
|
Some(StringVirtualFile1(r.id, content))
|
||||||
|
else None
|
||||||
|
// Digest(r) can throw NoSuchFileException
|
||||||
|
catch case _: NoSuchFileException => None
|
||||||
|
|
||||||
override def syncBlobs(refs: Seq[HashedVirtualFileRef], outputDirectory: Path): Seq[Path] =
|
override def syncBlobs(refs: Seq[HashedVirtualFileRef], outputDirectory: Path): Seq[Path] =
|
||||||
refs.flatMap: r =>
|
refs.flatMap: r =>
|
||||||
val casFile = toCasFile(Digest(r))
|
try
|
||||||
if casFile.toFile().exists then
|
val casFile = toCasFile(Digest(r))
|
||||||
// println(s"syncBlobs: $casFile exists for $r")
|
if casFile.toFile().exists then
|
||||||
Some(syncFile(r, casFile, outputDirectory))
|
// println(s"syncBlobs: $casFile exists for $r")
|
||||||
else None
|
Some(syncFile(r, casFile, outputDirectory))
|
||||||
|
else None
|
||||||
|
// Digest(r) can throw NoSuchFileException
|
||||||
|
catch case _: NoSuchFileException => None
|
||||||
|
|
||||||
def syncFile(ref: HashedVirtualFileRef, casFile: Path, outputDirectory: Path): Path =
|
def syncFile(ref: HashedVirtualFileRef, casFile: Path, outputDirectory: Path): Path =
|
||||||
val d = Digest(ref)
|
val d = Digest(ref)
|
||||||
|
|
@ -365,7 +371,10 @@ class DiskActionCacheStore(base: Path, converter: FileConverter) extends Abstrac
|
||||||
|
|
||||||
override def findBlobs(refs: Seq[HashedVirtualFileRef]): Seq[HashedVirtualFileRef] =
|
override def findBlobs(refs: Seq[HashedVirtualFileRef]): Seq[HashedVirtualFileRef] =
|
||||||
refs.flatMap: r =>
|
refs.flatMap: r =>
|
||||||
val casFile = toCasFile(Digest(r))
|
try
|
||||||
if casFile.toFile().exists then Some(r)
|
val casFile = toCasFile(Digest(r))
|
||||||
else None
|
if casFile.toFile().exists then Some(r)
|
||||||
|
else None
|
||||||
|
// Digest(r) can throw NoSuchFileException
|
||||||
|
catch case _: NoSuchFileException => None
|
||||||
end DiskActionCacheStore
|
end DiskActionCacheStore
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue