You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by GitBox <gi...@apache.org> on 2019/08/19 06:58:30 UTC

[GitHub] [zeppelin] alexott commented on a change in pull request #3428: [ZEPPELIN-4305] LocalStorageConfig.atomicWriteToFile throws exception

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:
users@infra.apache.org


With regards,
Apache Git Services