Hash calculation may throw exception w/ getModifiedTime(); fix

In Eval there is a calculation of hashes by scanning the elements
of classpath, and getting the last modification time of each
directory. When lastModified() was in use, non-existent elements
would return 0L, but getModifiedTime() will throw an exception
instead (like getLastModifiedTime(), incidentally).
So, we catch the FileNotFoundException and return 0L now as well.
This commit is contained in:
Antonio Cunei 2017-12-07 01:50:42 +01:00 committed by Eugene Yokota
parent 2129f8ceb5
commit 295bcff851
1 changed files with 6 additions and 2 deletions

View File

@ -487,8 +487,12 @@ private[sbt] object Eval {
if (fs eq null) filesModifiedBytes(Array[File]()) else seqBytes(fs)(fileModifiedBytes)
def fileModifiedBytes(f: File): Array[Byte] =
(if (f.isDirectory) filesModifiedBytes(f listFiles classDirFilter)
else bytes(getModifiedTime(f))) ++
bytes(f.getAbsolutePath)
else
bytes(try {
getModifiedTime(f)
} catch {
case _: java.io.FileNotFoundException => 0L
})) ++ bytes(f.getAbsolutePath)
def fileExistsBytes(f: File): Array[Byte] =
bytes(f.exists) ++
bytes(f.getAbsolutePath)