Skip to content

Commit 8ea871f

Browse files
author
Christophe Préaud
committed
Ensure that files are fetched atomically
tempFile is created in the same directory than targetFile, so that the move from tempFile to targetFile is always atomic
1 parent d1966f3 commit 8ea871f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ private[spark] object Utils extends Logging {
335335
def fetchFile(url: String, targetDir: File, conf: SparkConf, securityMgr: SecurityManager,
336336
hadoopConf: Configuration) {
337337
val filename = url.split("/").last
338-
val tempDir = getLocalDir(conf)
339-
val tempFile = File.createTempFile("fetchFileTemp", null, new File(tempDir))
338+
val tempFile = File.createTempFile("fetchFileTemp", null, new File(targetDir.getAbsolutePath))
340339
val targetFile = new File(targetDir, filename)
341340
val uri = new URI(url)
342341
val fileOverwrite = conf.getBoolean("spark.files.overwrite", defaultValue = false)

0 commit comments

Comments
 (0)