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:
Antonio Cunei 2017-12-18 17:24:22 +01:00
parent badb96efb4
commit 42f23e62aa
3 changed files with 8 additions and 9 deletions

View File

@ -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)

View File

@ -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) {

View File

@ -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)