flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From StephanEwen <...@git.apache.org>
Subject [GitHub] flink pull request #3598: [FLINK-6103] LocalFileSystem rename() uses File.re...
Date Fri, 24 Mar 2017 15:12:51 GMT
Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3598#discussion_r107925602
  
    --- Diff: flink-core/src/main/java/org/apache/flink/core/fs/local/LocalFileSystem.java
---
    @@ -262,8 +265,13 @@ public FSDataOutputStream create(
     	public boolean rename(final Path src, final Path dst) throws IOException {
     		final File srcFile = pathToFile(src);
     		final File dstFile = pathToFile(dst);
    -
    -		return srcFile.renameTo(dstFile);
    +		//Files.move fails if the destination directory doesn't exist
    +		if(dstFile.getParentFile()!= null && !dstFile.getParentFile().exists()){
    +			Files.createDirectories(dstFile.getParentFile().toPath());
    +		}
    +		//this throws an IOException if any error occurs
    +		Files.move(srcFile.toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
    --- End diff --
    
    I think that is inherited from the interface that is also used by the HdfsFileSystem.
The outcomes are `true`(rename success), `false` (rename failed), and `IOExeption` (communication
with filesystem failed).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message