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 09:35:04 GMT
Github user StephanEwen commented on a diff in the pull request:

    --- 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 --
    If we want to preserve the old semantics, we should catch the exception and return `false`
in that case.

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.

View raw message