mirror of https://github.com/sbt/sbt.git
When preserving last modified, convert negative values to 0
File.lastModified can return a negative number, but File.setLastModified doesn't accept negative numbers. See Java bug #6791812.
This commit is contained in:
parent
960d17c358
commit
1bc26fa488
|
|
@ -566,7 +566,12 @@ object IO
|
|||
if(preserveLastModified)
|
||||
copyLastModified(sourceFile, targetFile)
|
||||
}
|
||||
def copyLastModified(sourceFile: File, targetFile: File) = targetFile.setLastModified( sourceFile.lastModified )
|
||||
def copyLastModified(sourceFile: File, targetFile: File) = {
|
||||
val last = sourceFile.lastModified
|
||||
// lastModified can return a negative number, but setLastModified doesn't accept it
|
||||
// see Java bug #6791812
|
||||
targetFile.setLastModified( math.max(last, 0L) )
|
||||
}
|
||||
def defaultCharset = utf8
|
||||
|
||||
def write(file: File, content: String, charset: Charset = defaultCharset, append: Boolean = false): Unit =
|
||||
|
|
|
|||
Loading…
Reference in New Issue