Wei Zhong created FLINK-15244: --------------------------------- Summary: FileUtils#deleteDirectoryQuietly will delete files in the symbolic link which point to a directory Key: FLINK-15244 URL: https://issues.apache.org/jira/browse/FLINK-15244 Project: Flink Issue Type: Bug Affects Versions: 1.10.0 Reporter: Wei Zhong Fix For: 1.10.0
_FileUtils.deleteDirectoryQuietly_ will delete files in symbolic link which point to a directory. Currently the PyFlink uses this method to delete temporary folders generated during the job submission and python UDF execution, which contains the symbolic links which may point to users' libraries and directories in distributed cache. To resolve this problem we need to check if the directory is symbolic link in _FileUtils.deleteDirectoryInternal:_ {code:java} private static void deleteDirectoryInternal(File directory) throws IOException { // **We should check if the directory is symbolic link.** if (directory.isDirectory()) { // directory exists and is a directory // empty the directory first try { cleanDirectoryInternal(directory); } catch (FileNotFoundException ignored) { // someone concurrently deleted the directory, nothing to do for us return; } // delete the directory. this fails if the directory is not empty, meaning // if new files got concurrently created. we want to fail then. // if someone else deleted the empty directory concurrently, we don't mind // the result is the same for us, after all Files.deleteIfExists(directory.toPath()); } else if (directory.exists()) { // exists but is file, not directory // either an error from the caller, or concurrently a file got created throw new IOException(directory + " is not a directory"); } // else: does not exist, which is okay (as if deleted) } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)