Skip to content

Commit

Permalink
Merge pull request #1 from dwijnand/wip-milli
Browse files Browse the repository at this point in the history
Use IO.getModified over importing the method
  • Loading branch information
cunei committed Dec 15, 2017
2 parents cd4346c + 13a8d53 commit d172453
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler {
def newer(a: String, b: String): Unit = {
val pathA = fromString(a)
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) {
scriptError(s"$pathA is not newer than $pathB")
}
Expand Down
14 changes: 5 additions & 9 deletions util-cache/src/main/scala/sbt/util/FileInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ package sbt.util
import java.io.File
import java.io.FileNotFoundException
import scala.util.control.NonFatal
import sbt.io.Hash
import sbt.io.{ Hash, IO }
import sjsonnew.{ Builder, JsonFormat, Unbuilder, deserializationError }
import CacheImplicits._
import sbt.io.IO.getModifiedTime

sealed trait FileInfo { def file: File }
sealed trait HashFileInfo extends FileInfo { def hash: List[Byte] }
Expand Down Expand Up @@ -52,13 +51,10 @@ object FilesInfo {

object FileInfo {

def getModifiedTimeOrZero(file: File) = { // returns 0L if file does not exist
try {
getModifiedTime(file)
} catch {
case _: FileNotFoundException => 0L
}
}
// 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
Expand Down

0 comments on commit d172453

Please sign in to comment.