mirror of https://github.com/sbt/sbt.git
Revert *ModifiedTime() calls to *lastModified*() calls
There are just too many instances in which sbt's code relies on the `lastModified`/`setLastModified` semantics, so instead of moving to `get`/`setModifiedTime`, we use new IO calls that offer the new timestamp precision, but retain the old semantics.
This commit is contained in:
parent
96c88a4291
commit
8ba68eedfd
|
|
@ -69,7 +69,7 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler {
|
|||
val pathA = fromString(a)
|
||||
val pathB = fromString(b)
|
||||
val isNewer = pathA.exists &&
|
||||
(!pathB.exists || IO.getModifiedTime(pathA) > IO.getModifiedTime(pathB))
|
||||
(!pathB.exists || IO.lastModified(pathA) > IO.lastModified(pathB))
|
||||
if (!isNewer) {
|
||||
scriptError(s"$pathA is not newer than $pathB")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,11 +51,6 @@ object FilesInfo {
|
|||
|
||||
object FileInfo {
|
||||
|
||||
// returns 0L if file does not exist
|
||||
private def getModifiedTimeOrZero(file: File) =
|
||||
try IO.getModifiedTime(file)
|
||||
catch { case _: FileNotFoundException => 0L }
|
||||
|
||||
sealed trait Style {
|
||||
type F <: FileInfo
|
||||
|
||||
|
|
@ -95,7 +90,7 @@ object FileInfo {
|
|||
}
|
||||
|
||||
implicit def apply(file: File): HashModifiedFileInfo =
|
||||
FileHashModified(file.getAbsoluteFile, Hash(file).toList, getModifiedTimeOrZero(file))
|
||||
FileHashModified(file.getAbsoluteFile, Hash(file).toList, IO.lastModified(file))
|
||||
}
|
||||
|
||||
object hash extends Style {
|
||||
|
|
@ -152,7 +147,7 @@ object FileInfo {
|
|||
}
|
||||
|
||||
implicit def apply(file: File): ModifiedFileInfo =
|
||||
FileModified(file.getAbsoluteFile, getModifiedTimeOrZero(file))
|
||||
FileModified(file.getAbsoluteFile, IO.lastModified(file))
|
||||
}
|
||||
|
||||
object exists extends Style {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import sbt.io.IO
|
|||
|
||||
class FileInfoSpec extends UnitSpec {
|
||||
val file = new java.io.File(".").getAbsoluteFile
|
||||
val fileInfo: ModifiedFileInfo = FileModified(file, IO.getModifiedTime(file))
|
||||
val fileInfo: ModifiedFileInfo = FileModified(file, IO.lastModified(file))
|
||||
val filesInfo = FilesInfo(Set(fileInfo))
|
||||
|
||||
it should "round trip" in assertRoundTrip(filesInfo)
|
||||
|
|
|
|||
Loading…
Reference in New Issue