Skip to content

Commit

Permalink
[FLINK-7266] [core] Prevent attempt for parent directory deletion for…
Browse files Browse the repository at this point in the history
… object stores

This closes apache#4397
  • Loading branch information
StephanEwen authored and aljoscha committed Nov 17, 2017
1 parent f29f805 commit b00f1b3
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.flink.core.fs.FSDataInputStream;
import org.apache.flink.core.fs.FileSystem;
import org.apache.flink.core.fs.FileSystemKind;
import org.apache.flink.core.fs.Path;
import org.apache.flink.runtime.state.StreamStateHandle;
import org.apache.flink.util.FileUtils;
Expand Down Expand Up @@ -77,14 +78,15 @@ public FSDataInputStream openInputStream() throws IOException {
*/
@Override
public void discardState() throws Exception {

FileSystem fs = getFileSystem();

fs.delete(filePath, false);

try {
FileUtils.deletePathIfEmpty(fs, filePath.getParent());
} catch (Exception ignored) {}
if (fs.getKind() == FileSystemKind.FILE_SYSTEM) {
try {
FileUtils.deletePathIfEmpty(fs, filePath.getParent());
} catch (Exception ignored) {}
}
}

/**
Expand Down

0 comments on commit b00f1b3

Please sign in to comment.