Search in sources :

Example 1 with PathIsNotDirectoryException

use of org.apache.hadoop.fs.PathIsNotDirectoryException in project hadoop by apache.

the class CommandWithDestination method recursePath.

@Override
protected void recursePath(PathData src) throws IOException {
    PathData savedDst = dst;
    try {
        // modify dst as we descend to append the basename of the
        // current directory being processed
        dst = getTargetPath(src);
        final boolean preserveRawXattrs = checkPathsForReservedRaw(src.path, dst.path);
        if (dst.exists) {
            if (!dst.stat.isDirectory()) {
                throw new PathIsNotDirectoryException(dst.toString());
            }
        } else {
            if (!dst.fs.mkdirs(dst.path)) {
                // too bad we have no clue what failed
                PathIOException e = new PathIOException(dst.toString());
                e.setOperation("mkdir");
                throw e;
            }
            // need to update stat to know it exists now
            dst.refreshStatus();
        }
        super.recursePath(src);
        if (dst.stat.isDirectory()) {
            preserveAttributes(src, dst, preserveRawXattrs);
        }
    } finally {
        dst = savedDst;
    }
}
Also used : PathIOException(org.apache.hadoop.fs.PathIOException) PathIsNotDirectoryException(org.apache.hadoop.fs.PathIsNotDirectoryException)

Aggregations

PathIOException (org.apache.hadoop.fs.PathIOException)1 PathIsNotDirectoryException (org.apache.hadoop.fs.PathIsNotDirectoryException)1