From 42f23e62aa46b811e4fbf03b14a8365c5da9cf92 Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Mon, 18 Dec 2017 17:24:22 +0100 Subject: [PATCH 1/4] 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. --- .../sbt/librarymanagement/RichUpdateReport.scala | 11 +++++------ .../ivyint/GigahorseUrlHandler.scala | 2 +- project/Util.scala | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/src/main/scala/sbt/librarymanagement/RichUpdateReport.scala b/core/src/main/scala/sbt/librarymanagement/RichUpdateReport.scala index d8e5ca795..3d7eb933c 100644 --- a/core/src/main/scala/sbt/librarymanagement/RichUpdateReport.scala +++ b/core/src/main/scala/sbt/librarymanagement/RichUpdateReport.scala @@ -16,12 +16,11 @@ final class RichUpdateReport(report: UpdateReport) { .map( f => (f, - // TODO: this used to be a lastModified(), without error checking. - // On occasion, "files" contains files like "./target/ivyhome/resolution-cache/com.example/foo/0.4.0/resolved.xml.xml", - // which do not actually exist, so getModifiedTime() correctly throws an exception. For the moment, the behavior of - // lastModified() is reproduced, but the non-existent file should really not be there to begin with. so, FIXME. - try IO.getModifiedTime(f) - catch { case _: FileNotFoundException => 0L }) + // TODO: The list of files may also contain some odd files that do not actually exist like: + // "./target/ivyhome/resolution-cache/com.example/foo/0.4.0/resolved.xml.xml". + // IO.lastModified() will just return zero, but the list of files should not contain such + // files to begin with, in principle. + IO.lastModified(f) ) .toMap UpdateReport(report.cachedDescriptor, report.configurations, report.stats, stamps) diff --git a/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala b/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala index 32bbaf516..1a25a3202 100644 --- a/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala +++ b/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala @@ -149,7 +149,7 @@ class GigahorseUrlHandler extends AbstractURLHandler { val lastModified = lastModifiedTimestamp(response) if (lastModified > 0) { - IO.setModifiedTime(dest, lastModified) + IO.setLastModified(dest, lastModified) } if (l != null) { diff --git a/project/Util.scala b/project/Util.scala index 2ef855762..5c63dd1de 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -26,8 +26,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) From 72dd0064c3791ad4a6a2ba1904d8cf12322aede3 Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Fri, 22 Dec 2017 00:24:48 +0100 Subject: [PATCH 2/4] Change modifiedTime definitions --- .../main/scala/sbt/librarymanagement/RichUpdateReport.scala | 4 ++-- .../librarymanagement/ivyint/GigahorseUrlHandler.scala | 2 +- project/Util.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/scala/sbt/librarymanagement/RichUpdateReport.scala b/core/src/main/scala/sbt/librarymanagement/RichUpdateReport.scala index 3d7eb933c..97f672faa 100644 --- a/core/src/main/scala/sbt/librarymanagement/RichUpdateReport.scala +++ b/core/src/main/scala/sbt/librarymanagement/RichUpdateReport.scala @@ -18,9 +18,9 @@ final class RichUpdateReport(report: UpdateReport) { (f, // TODO: The list of files may also contain some odd files that do not actually exist like: // "./target/ivyhome/resolution-cache/com.example/foo/0.4.0/resolved.xml.xml". - // IO.lastModified() will just return zero, but the list of files should not contain such + // IO.getModifiedTimeOrZero() will just return zero, but the list of files should not contain such // files to begin with, in principle. - IO.lastModified(f) + IO.getModifiedTimeOrZero(f)) ) .toMap UpdateReport(report.cachedDescriptor, report.configurations, report.stats, stamps) diff --git a/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala b/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala index 1a25a3202..b8da74aab 100644 --- a/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala +++ b/ivy/src/main/scala/sbt/internal/librarymanagement/ivyint/GigahorseUrlHandler.scala @@ -149,7 +149,7 @@ class GigahorseUrlHandler extends AbstractURLHandler { val lastModified = lastModifiedTimestamp(response) if (lastModified > 0) { - IO.setLastModified(dest, lastModified) + IO.setModifiedTimeOrFalse(dest, lastModified) } if (l != null) { diff --git a/project/Util.scala b/project/Util.scala index 5c63dd1de..3b1ead60a 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -26,7 +26,7 @@ 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.IO.lastModified(), once the build + // TODO: replace lastModified() with sbt.io.IO.getModifiedTimeOrZero(), 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) From b53c37b54f9f94703f2efb2e4f60da2d4532d3ab Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 22 Dec 2017 08:35:11 -0500 Subject: [PATCH 3/4] IO 1.1.3 and Util 1.1.2 --- project/Dependencies.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 1a71abf72..3d4a59e93 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -6,8 +6,8 @@ object Dependencies { val scala211 = "2.11.12" val scala212 = "2.12.4" - private val ioVersion = "1.1.2" - private val utilVersion = "1.1.1" + private val ioVersion = "1.1.3" + private val utilVersion = "1.1.2" private val sbtIO = "org.scala-sbt" %% "io" % ioVersion From fa472179f5aa7deb07e0126cca4e7a9c07bf268b Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 22 Dec 2017 08:35:26 -0500 Subject: [PATCH 4/4] sbt 1.0.4 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 94005e587..394cb75cf 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.0.0 +sbt.version=1.0.4