Author: bobby
Date: Wed Jul 25 13:58:44 2012
New Revision: 1365590
URL: http://svn.apache.org/viewvc?rev=1365590&view=rev
Log:
svn merge -c 1365588 FIXES: HADOOP-8551. fs -mkdir creates parent directories
without the -p option (John George via bobby)
Modified:
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
Modified:
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1365590&r1=1365589&r2=1365590&view=diff
==============================================================================
---
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
(original)
+++
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
Wed Jul 25 13:58:44 2012
@@ -117,6 +117,9 @@ Release 0.23.3 - UNRELEASED
HADOOP-8606. FileSystem.get may return the wrong filesystem (Daryn Sharp
via bobby)
+ HADOOP-8551. fs -mkdir creates parent directories without the -p option
+ (John George via bobby)
+
Release 0.23.2 - UNRELEASED
NEW FEATURES
Modified:
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java?rev=1365590&r1=1365589&r2=1365590&view=diff
==============================================================================
---
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
(original)
+++
hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Mkdir.java
Wed Jul 25 13:58:44 2012
@@ -23,9 +23,11 @@ import java.util.LinkedList;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.shell.PathExceptions.PathExistsException;
import org.apache.hadoop.fs.shell.PathExceptions.PathIOException;
import org.apache.hadoop.fs.shell.PathExceptions.PathIsNotDirectoryException;
+import org.apache.hadoop.fs.shell.PathExceptions.PathNotFoundException;
/**
* Create the given dir
@@ -66,7 +68,11 @@ class Mkdir extends FsCommand {
@Override
protected void processNonexistentPath(PathData item) throws IOException {
- // TODO: should use createParents to control intermediate dir creation
+ // check if parent exists. this is complicated because getParent(a/b/c/)
returns a/b/c, but
+ // we want a/b
+ if (!item.fs.exists(new Path(item.path.toString()).getParent()) &&
!createParents) {
+ throw new PathNotFoundException(item.toString());
+ }
if (!item.fs.mkdirs(item.path)) {
throw new PathIOException(item.toString());
}