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
bef5c9c996
commit
ebff7919e9
|
|
@ -485,12 +485,11 @@ private[sbt] object Eval {
|
|||
def filesModifiedBytes(fs: Array[File]): Array[Byte] =
|
||||
if (fs eq null) filesModifiedBytes(Array[File]()) else seqBytes(fs)(fileModifiedBytes)
|
||||
def fileModifiedBytes(f: File): Array[Byte] =
|
||||
(if (f.isDirectory) filesModifiedBytes(f listFiles classDirFilter)
|
||||
(if (f.isDirectory)
|
||||
filesModifiedBytes(f listFiles classDirFilter)
|
||||
else
|
||||
bytes(
|
||||
try IO.getModifiedTime(f)
|
||||
catch { case _: java.io.FileNotFoundException => 0L })) ++
|
||||
bytes(f.getAbsolutePath)
|
||||
bytes(IO.lastModified(f))
|
||||
) ++ bytes(f.getAbsolutePath)
|
||||
def fileExistsBytes(f: File): Array[Byte] =
|
||||
bytes(f.exists) ++
|
||||
bytes(f.getAbsolutePath)
|
||||
|
|
|
|||
|
|
@ -2315,7 +2315,7 @@ object Classpaths {
|
|||
case Some(period) =>
|
||||
val fullUpdateOutput = cacheDirectory / "out"
|
||||
val now = System.currentTimeMillis
|
||||
val diff = now - IO.getModifiedTime(fullUpdateOutput)
|
||||
val diff = now - IO.lastModified(fullUpdateOutput)
|
||||
val elapsedDuration = new FiniteDuration(diff, TimeUnit.MILLISECONDS)
|
||||
fullUpdateOutput.exists() && elapsedDuration > period
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ private[sbt] object LibraryManagement {
|
|||
}
|
||||
|
||||
private[this] def fileUptodate(file: File, stamps: Map[File, Long]): Boolean =
|
||||
stamps.get(file).forall(_ == IO.getModifiedTime(file))
|
||||
stamps.get(file).forall(_ == IO.lastModified(file))
|
||||
|
||||
private[sbt] def transitiveScratch(
|
||||
lm: DependencyResolution,
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ object SiteMap {
|
|||
// generates a string suitable for a sitemap file representing the last modified time of the given File
|
||||
private[this] def lastModifiedString(f: File): String = {
|
||||
val formatter = new java.text.SimpleDateFormat("yyyy-MM-dd")
|
||||
// TODO: replace lastModified() with sbt.io.Milli.getModifiedTime(), once the build
|
||||
// has been upgraded to a version of sbt that includes sbt.io.Milli.
|
||||
// TODO: replace lastModified() with sbt.io.IO.lastModified(), once the build
|
||||
// has been upgraded to a version of sbt that includes that call.
|
||||
formatter.format(new java.util.Date(f.lastModified))
|
||||
}
|
||||
// writes the provided XML node to `output` and then gzips it to `gzipped` if `gzip` is true
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ object Util {
|
|||
val timestamp = formatter.format(new Date)
|
||||
val content = versionLine(version) + "\ntimestamp=" + timestamp
|
||||
val f = dir / "xsbt.version.properties"
|
||||
// TODO: replace lastModified() with sbt.io.Milli.getModifiedTime(), once the build
|
||||
// has been upgraded to a version of sbt that includes sbt.io.Milli.
|
||||
// TODO: replace lastModified() with sbt.io.IO.lastModified(), once the build
|
||||
// has been upgraded to a version of sbt that includes that call.
|
||||
if (!f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f, version)) {
|
||||
s.log.info("Writing version information to " + f + " :\n" + content)
|
||||
IO.write(f, content)
|
||||
|
|
|
|||
Loading…
Reference in New Issue