alexott commented on a change in pull request #3428: [ZEPPELIN-4305]
LocalStorageConfig.atomicWriteToFile throws exception
URL: https://github.com/apache/zeppelin/pull/3428#discussion_r315061229
##########
File path:
zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java
##########
@@ -123,8 +123,9 @@ private void atomicWriteToFile(String content, File file)
throws IOException {
Path destinationFilePath =
defaultFileSystem.getPath(file.getCanonicalPath());
try {
file.getParentFile().mkdirs();
- Files.move(tempFile.toPath(), destinationFilePath,
- StandardCopyOption.ATOMIC_MOVE);
+ Path tempDestinationFile =
defaultFileSystem.getPath(file.getCanonicalPath() + ".tmp");
+ Files.move(tempFile.toPath(), tempDestinationFile);
Review comment:
Thank you for review @felixcheung
I've pushed small improvements after your comment, although you can ignore
intermediate commit.
The main change that was done is to extract temporary file into the
destination directory, so we always can use atomic move because the files are
guaranteed on the same file system.
Or we can use intermediate version that extracts into temporary directory,
and then performs 2 moves...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services