Skip to content

Commit

Permalink
Ensure that files are fetched atomically
Browse files Browse the repository at this point in the history
tempFile is created in the same directory than targetFile, so that the
move from tempFile to targetFile is always atomic
  • Loading branch information
Christophe Préaud committed Nov 3, 2014
1 parent 54419ae commit 9ba89ca
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ private[spark] object Utils extends Logging {
conf: SparkConf,
securityMgr: SecurityManager,
hadoopConf: Configuration) {
val tempDir = getLocalDir(conf)
val tempFile = File.createTempFile("fetchFileTemp", null, new File(tempDir))
val tempFile = File.createTempFile("fetchFileTemp", null, new File(targetDir.getAbsolutePath))
val targetFile = new File(targetDir, filename)
val uri = new URI(url)
val fileOverwrite = conf.getBoolean("spark.files.overwrite", defaultValue = false)
Expand Down

0 comments on commit 9ba89ca

Please sign in to comment.