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

    https://github.com/apache/spark/pull/14371#discussion_r72320003
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/SparkHadoopUtil.scala 
---
    @@ -404,6 +404,27 @@ class SparkHadoopUtil extends Logging {
         }
         buffer.toString
       }
    +
    +  /**
    +   * Delete a directory if it exists. If the `FileSystem.delete` operation 
returns false,
    +   * the path is checked for existence. If it is still there, a warning is 
printed.
    +   * @param fs filesystem
    +   * @param path path to delete
    +   * @param recursive recursive flag
    +   * @return true if there is no file/directory at the end of the path. 
That is: the delete worked.
    +   */
    +  def delete(fs: FileSystem, path: Path, recursive: Boolean): Boolean = {
    +    if (!fs.delete(path, recursive)) {
    +      if (fs.exists(path)) {
    +        logWarning(s"Error deleting $path")
    +        false
    +      } else {
    +        true
    +      }
    +    } else {
    +      true
    --- End diff --
    
    You could return `true` once at the end and then collapse this to a single 
`if` statement with one block. I guess the point of this construct over just 
`fs.delete` is to log a warning, but I'm not even sure we need that even where 
that's what the code does now. Could be simpler to standardize on simple 
`fs.delete` everywhere.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to