[
https://issues.apache.org/jira/browse/HDFS-9123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14904029#comment-14904029
]
Yongjun Zhang commented on HDFS-9123:
-------------------------------------
Hi [~jojochuang],
Thanks for reporting the issue and the patch. It looks good in general and I
have some minor comments:
1. Suggest to change
{code}
String pathEnd = "";
if(!srcPath.toString().endsWith(Path.SEPARATOR)){
pathEnd = Path.SEPARATOR;
}
if(dstPath.startsWith(srcPath+pathEnd)) {
{code}
to
{code}
if (!srcPath.endsWith(Path.SEPARATOR)) {
srcPath += Path.SEPARATOR;
}
if(dstPath.startsWith(srcPath)) {
{code}
2. The test looks good, i can see that it report the "cp: `/' to `/test/': is a
subdirectory of itself" message with the fix. However, if I remove the fix and
run the same test, it's supposed to fail but it doesn't. Would you please look
into?
Thanks.
> Validation of a path ended with a '/'
> -------------------------------------
>
> Key: HDFS-9123
> URL: https://issues.apache.org/jira/browse/HDFS-9123
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: fs
> Reporter: Wei-Chiu Chuang
> Assignee: Wei-Chiu Chuang
> Priority: Minor
> Attachments: HDFS-9123.001.patch, HDFS-9123.002.patch
>
>
> HDFS forbids copying from a directory to its subdirectory (e.g. hdfs dfs -cp
> /abc /abc/xyz) as otherwise it could cause infinite copying (/abc/xyz/xyz,
> /abc/xyz/xyz, /abc/xyz/xyz/xyz,... etc)
> However, if the source path is ended with a '/' path separator, the existing
> validation for sub-directories fails. For example, copying from / to /abc
> would cause infinite copying, until the disk space is filled up.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)