You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Hadoop QA (JIRA)" <ji...@apache.org> on 2013/07/09 14:07:48 UTC
[jira] [Commented] (HADOOP-9705) FsShell cp -p does not preserve
directory attibutes
[ https://issues.apache.org/jira/browse/HADOOP-9705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13703198#comment-13703198 ]
Hadoop QA commented on HADOOP-9705:
-----------------------------------
{color:green}+1 overall{color}. Here are the results of testing the latest attachment
http://issues.apache.org/jira/secure/attachment/12591423/HADOOP-9705.patch
against trunk revision .
{color:green}+1 @author{color}. The patch does not contain any @author tags.
{color:green}+1 tests included{color}. The patch appears to include 1 new or modified test files.
{color:green}+1 javac{color}. The applied patch does not increase the total number of javac compiler warnings.
{color:green}+1 javadoc{color}. The javadoc tool did not generate any warning messages.
{color:green}+1 eclipse:eclipse{color}. The patch built with eclipse:eclipse.
{color:green}+1 findbugs{color}. The patch does not introduce any new Findbugs (version 1.3.9) warnings.
{color:green}+1 release audit{color}. The applied patch does not increase the total number of release audit warnings.
{color:green}+1 core tests{color}. The patch passed unit tests in hadoop-common-project/hadoop-common.
{color:green}+1 contrib tests{color}. The patch passed contrib unit tests.
Test results: https://builds.apache.org/job/PreCommit-HADOOP-Build/2754//testReport/
Console output: https://builds.apache.org/job/PreCommit-HADOOP-Build/2754//console
This message is automatically generated.
> FsShell cp -p does not preserve directory attibutes
> ---------------------------------------------------
>
> Key: HADOOP-9705
> URL: https://issues.apache.org/jira/browse/HADOOP-9705
> Project: Hadoop Common
> Issue Type: Bug
> Components: fs
> Affects Versions: 3.0.0, 2.0.4-alpha
> Reporter: Stephen Chu
> Attachments: HADOOP-9705.patch
>
>
> HADOOP-9338 added the -p flag to preserve file attributes when copying.
> However, cp -p does not preserve directory attributes. It'd be useful to add this functionality.
> For example, the following shows that the modified time is not preserved
> {code}
> [schu@hdfs-snapshots-1 ~]$ $HADOOP_HOME/bin/hdfs dfs -mkdir /user/schu/testDir1
> [schu@hdfs-snapshots-1 ~]$ $HADOOP_HOME/bin/hdfs dfs -ls /user/schu/
> Found 1 items
> drwxr-xr-x - schu supergroup 0 2013-07-07 20:25 /user/schu/testDir1
> [schu@hdfs-snapshots-1 ~]$ $HADOOP_HOME/bin/hdfs dfs -cp -p /user/schu/testDir1 /user/schu/testDir2
> [schu@hdfs-snapshots-1 ~]$ $HADOOP_HOME/bin/hdfs dfs -ls /user/schu
> Found 2 items
> drwxr-xr-x - schu supergroup 0 2013-07-07 20:25 /user/schu/testDir1
> drwxr-xr-x - schu supergroup 0 2013-07-07 20:35 /user/schu/testDir2
> [schu@hdfs-snapshots-1 ~]$
> {code}
> The preserve logic is in CommandWithDestination#copyFileToTarget, which is only called with files.
> {code}
> protected void processPath(PathData src, PathData dst) throws IOException {
> if (src.stat.isSymlink()) {
> // TODO: remove when FileContext is supported, this needs to either
> // copy the symlink or deref the symlink
> throw new PathOperationException(src.toString());
> } else if (src.stat.isFile()) {
> copyFileToTarget(src, dst);
> } else if (src.stat.isDirectory() && !isRecursive()) {
> throw new PathIsDirectoryException(src.toString());
> }
> }
> {code}
> {code}
> /**
> * Copies the source file to the target.
> * @param src item to copy
> * @param target where to copy the item
> * @throws IOException if copy fails
> */
> protected void copyFileToTarget(PathData src, PathData target) throws IOException {
> src.fs.setVerifyChecksum(verifyChecksum);
> if (src != null) {
> throw new PathExistsException("hi");
> }
> InputStream in = null;
> try {
> in = src.fs.open(src.path);
> copyStreamToTarget(in, target);
> if(preserve) {
> target.fs.setTimes(
> target.path,
> src.stat.getModificationTime(),
> src.stat.getAccessTime());
> target.fs.setOwner(
> target.path,
> src.stat.getOwner(),
> src.stat.getGroup());
> target.fs.setPermission(
> target.path,
> src.stat.getPermission());
> System.out.println("Preserving");
> if (src.fs.equals(target.fs)) {
> System.out.println("Same filesystems");
> src.fs.preserveAttributes(src.path, target.path);
> }
> throw new IOException("hi");
> }
> } finally {
> IOUtils.closeStream(in);
> }
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira