Skip to content

Commit

Permalink
Fix a bug of Utils.findOldestFiles(). file.lastModified is returned i…
Browse files Browse the repository at this point in the history
…n milliseconds.
  • Loading branch information
Kelvin Chu authored and Evan Chan committed Apr 3, 2014
1 parent ad99955 commit 72f7d2d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,13 @@ private[spark] object Utils extends Logging {
/**
* Finds all the files in a directory whose last modified time is older than cutoff seconds.
* @param dir must be the path to a directory, or IllegalArgumentException is thrown
* @param cutoff filter for files is lastModified < (currentTimeMillis/1000 - cutoff)
* @param cutoff measured in seconds. Files older than this are returned.
*/
def findOldestFiles(dir: File, cutoff: Long): Seq[File] = {
val currentTimeSecs = System.currentTimeMillis / 1000
if (dir.isDirectory) {
val files = listFilesSafely(dir)
files.filter { file => file.lastModified < (currentTimeSecs - cutoff) }
files.filter { file => file.lastModified < (currentTimeSecs - cutoff * 1000) }
} else {
throw new IllegalArgumentException(dir + " is not a directory!")
}
Expand Down

0 comments on commit 72f7d2d

Please sign in to comment.