mirror of https://github.com/sbt/sbt.git
Use NIO Files.getLastModifiedTime for hashing
This commit is contained in:
parent
04d6a8b44c
commit
ad3692b2df
|
|
@ -509,11 +509,22 @@ private[sbt] object Eval {
|
|||
if (f.isDirectory)
|
||||
(f listFiles classDirFilter) foreach { x =>
|
||||
fileModifiedHash(x, digester)
|
||||
} else digester.update(bytes(IO.getModifiedTimeOrZero(f)))
|
||||
} else digester.update(bytes(JavaMilli.getModifiedTimeOrZero(f)))
|
||||
|
||||
digester.update(bytes(f.getAbsolutePath))
|
||||
}
|
||||
|
||||
// This uses NIO instead of the JNA-based IO.getModifiedTimeOrZero for speed
|
||||
object JavaMilli {
|
||||
import java.nio.file.{ Files, NoSuchFileException }
|
||||
def getModifiedTimeOrZero(f: File): Long =
|
||||
try {
|
||||
Files.getLastModifiedTime(f.toPath).toMillis
|
||||
} catch {
|
||||
case e: NoSuchFileException => 0L
|
||||
}
|
||||
}
|
||||
|
||||
def fileExistsBytes(f: File): Array[Byte] =
|
||||
bytes(f.exists) ++
|
||||
bytes(f.getAbsolutePath)
|
||||
|
|
|
|||
Loading…
Reference in New Issue