Skip to content

Commit 16bc77b

Browse files
Christophe PréaudJoshRosen
Christophe Préaud
authored andcommitted
[SPARK-4764] 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 Author: Christophe Préaud <christophe.preaud@kelkoo.com> Closes #2855 from preaudc/master and squashes the following commits: 9ba89ca [Christophe Préaud] Ensure that files are fetched atomically 54419ae [Christophe Préaud] Merge remote-tracking branch 'upstream/master' c6a5590 [Christophe Préaud] Revert commit 8ea871f 7456a33 [Christophe Préaud] Merge remote-tracking branch 'upstream/master' 8ea871f [Christophe Préaud] Ensure that files are fetched atomically (cherry picked from commit ab2abcb) Signed-off-by: Josh Rosen <rosenville@gmail.com> Conflicts: core/src/main/scala/org/apache/spark/util/Utils.scala
1 parent 8ee2d18 commit 16bc77b

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
@@ -378,8 +378,7 @@ private[spark] object Utils extends Logging {
378378
*/
379379
def fetchFile(url: String, targetDir: File, conf: SparkConf, securityMgr: SecurityManager) {
380380
val filename = url.split("/").last
381-
val tempDir = getLocalDir(conf)
382-
val tempFile = File.createTempFile("fetchFileTemp", null, new File(tempDir))
381+
val tempFile = File.createTempFile("fetchFileTemp", null, new File(targetDir.getAbsolutePath))
383382
val targetFile = new File(targetDir, filename)
384383
val uri = new URI(url)
385384
val fileOverwrite = conf.getBoolean("spark.files.overwrite", false)

0 commit comments

Comments
 (0)