Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/4880#discussion_r25740726
--- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
@@ -643,7 +645,12 @@ private[spark] object Utils extends Logging {
fileOverwrite)
} else {
val in = fs.open(innerPath)
- val targetFile = new File(targetDir, innerPath.getName)
+ val targetFile: File =
+ if (!filename.isEmpty) {
+ new File(targetDir, filename)
+ } else {
+ new File(targetDir, innerPath.getName)
+ }
--- End diff --
Is this correct? If `path` refers to a directory with multiple files in it,
then this will fetch all of those files using the same name, overwriting all
but the last one fetched. IIUC we need to differentiate between `path` being a
directory from it being a file in the beginning of this method:
```
// L641, before the listStatus logic
if (fs.isFile(path)) {
val targetFile = new File(targetDir, filename.getOrElse(path.getName))
val in = fs.open(path)
downloadFile(path.toString, in, targetFile, fileOverwrite)
} else {
... // do the listStatus thing we've been doing before
}
```
where `filename` should be set if and only if the path refers to a file.
---
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]