HDFS-9881. DistributedFileSystem#getTrashRoot returns incorrect path for encryption zones.

This commit is contained in:
Andrew Wang 2016-03-01 16:35:39 -08:00
parent e76b13c415
commit 4abb2fa687
3 changed files with 12 additions and 1 deletions

View File

@ -2355,7 +2355,7 @@ public Path getTrashRoot(Path path) {
EncryptionZone ez = dfs.getEZForPath(parentSrc);
if ((ez != null)) {
return this.makeQualified(
new Path(ez.getPath(), FileSystem.TRASH_PREFIX +
new Path(new Path(ez.getPath(), FileSystem.TRASH_PREFIX),
dfs.ugi.getShortUserName()));
}
} catch (IOException e) {

View File

@ -2864,6 +2864,9 @@ Release 2.8.0 - UNRELEASED
HDFS-9870. Remove unused imports from DFSUtil.
(Brahma Reddy Battula via cnauroth)
HDFS-9881. DistributedFileSystem#getTrashRoot returns incorrect path for
encryption zones. (wang)
Release 2.7.3 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -1445,6 +1445,14 @@ public void testRootDirEZTrash() throws Exception {
private void verifyShellDeleteWithTrash(FsShell shell, Path path)
throws Exception{
try {
Path trashDir = shell.getCurrentTrashDir(path);
// Verify that trashDir has a path component named ".Trash"
Path checkTrash = trashDir;
while (!checkTrash.isRoot() && !checkTrash.getName().equals(".Trash")) {
checkTrash = checkTrash.getParent();
}
assertEquals("No .Trash component found in trash dir " + trashDir,
".Trash", checkTrash.getName());
final Path trashFile =
new Path(shell.getCurrentTrashDir(path) + "/" + path);
String[] argv = new String[]{"-rm", "-r", path.toString()};