Github user velvia commented on a diff in the pull request:

    https://github.com/apache/spark/pull/288#discussion_r11231160
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -537,6 +537,21 @@ 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 measured in seconds. Files older than this are returned.
    +   */
    +  def findOldFiles(dir: File, cutoff: Long): Seq[File] = {
    +    val currentTimeMillis = System.currentTimeMillis
    +    if (dir.isDirectory) {
    +      val files = listFilesSafely(dir)
    +      files.filter { file => file.lastModified < (currentTimeMillis - 
cutoff * 1000) }
    +    } else {
    +      throw new IllegalArgumentException(dir + " is not a directory!")
    +    }
    +  }
    --- End diff --
    
    Easier to test for sure.  I just prefer smaller more functional pieces of 
code in general for easier testing and to limit side effects.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to