Merge pull request #1 from dwijnand/wip-milli

Use IO.getModified over importing the method
This commit is contained in:
cunei 2017-12-15 17:20:38 +01:00 committed by GitHub
commit d17245344d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -68,7 +68,8 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler {
def newer(a: String, b: String): Unit = { def newer(a: String, b: String): Unit = {
val pathA = fromString(a) val pathA = fromString(a)
val pathB = fromString(b) val pathB = fromString(b)
val isNewer = pathA.exists && (!pathB.exists || getModifiedTime(pathA) > getModifiedTime(pathB)) val isNewer = pathA.exists &&
(!pathB.exists || IO.getModifiedTime(pathA) > IO.getModifiedTime(pathB))
if (!isNewer) { if (!isNewer) {
scriptError(s"$pathA is not newer than $pathB") scriptError(s"$pathA is not newer than $pathB")
} }

View File

@ -6,10 +6,9 @@ package sbt.util
import java.io.File import java.io.File
import java.io.FileNotFoundException import java.io.FileNotFoundException
import scala.util.control.NonFatal import scala.util.control.NonFatal
import sbt.io.Hash import sbt.io.{ Hash, IO }
import sjsonnew.{ Builder, JsonFormat, Unbuilder, deserializationError } import sjsonnew.{ Builder, JsonFormat, Unbuilder, deserializationError }
import CacheImplicits._ import CacheImplicits._
import sbt.io.IO.getModifiedTime
sealed trait FileInfo { def file: File } sealed trait FileInfo { def file: File }
sealed trait HashFileInfo extends FileInfo { def hash: List[Byte] } sealed trait HashFileInfo extends FileInfo { def hash: List[Byte] }
@ -52,13 +51,10 @@ object FilesInfo {
object FileInfo { object FileInfo {
def getModifiedTimeOrZero(file: File) = { // returns 0L if file does not exist // returns 0L if file does not exist
try { private def getModifiedTimeOrZero(file: File) =
getModifiedTime(file) try IO.getModifiedTime(file)
} catch { catch { case _: FileNotFoundException => 0L }
case _: FileNotFoundException => 0L
}
}
sealed trait Style { sealed trait Style {
type F <: FileInfo type F <: FileInfo