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

    https://github.com/apache/spark/pull/288#discussion_r11222616
  
    --- 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 --
    
    Is there a reason for not making this `deleteOldFiles` directly? I don't 
see another use case for getting old files other than deleting them. Is this 
because we need it for testing?


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