[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
Why need to create a new File here: `new File(targetDir.getAbsolutePath)`? Can't we use `targetDir` directly?