From 72f7d2d44805084472a7f354ee2b2355e92d3350 Mon Sep 17 00:00:00 2001 From: Kelvin Chu Date: Wed, 2 Apr 2014 00:19:49 -0700 Subject: [PATCH] Fix a bug of Utils.findOldestFiles(). file.lastModified is returned in milliseconds. --- core/src/main/scala/org/apache/spark/util/Utils.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 652ac7118f9cc..891caed156776 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -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!") }