Yang Jie created HADOOP-20064:
---------------------------------
Summary: FileUtil#copy ignores a failed child copy and deletes the
source directory when deleteSource is true
Key: HADOOP-20064
URL: https://issues.apache.org/jira/browse/HADOOP-20064
Project: Hadoop Common
Issue Type: Bug
Components: fs
Reporter: Yang Jie
The recursive FileUtil#copy overloads (FileSystem to FileSystem, File to
FileSystem, FileSystem to File) copy each entry of a directory and ignore the
boolean that the copy of the entry returns. An entry returns false when
creating its destination directory fails without an exception, for example when
mkdirs returns false for permission denied on the local file system, or when an
FTP server refuses it. The parent goes on, returns true and, with
deleteSource=true, deletes the whole source directory.
Example: {{hdfs.moveToLocalFile(/warehouse/t, /data/export)}} where
/data/export/t already exists and is not writable, and /warehouse/t only
contains partition directories. Every child mkdirs fails, nothing is copied,
and /warehouse/t is deleted permanently (delete does not use the trash). The
same code is used by LocalFileSystem#moveFromLocalFile and by the copy fallback
of RawLocalFileSystem#rename.
The fix copies the remaining entries, remembers the failure, and returns false
before deleting the source directory, like copy(Path[]) in the same class does
for a failed source. Entries that were copied are still moved; the failed entry
and the directory itself are kept.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]