HADOOP-6145. Fix FsShell rm/rmr error messages when there is a FNFE. Contributed by Jakob Homan

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@793987 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2009-07-14 17:39:33 +00:00
parent c02527fd04
commit 466f93c8b6
2 changed files with 13 additions and 5 deletions

View File

@ -1014,6 +1014,9 @@ Release 0.20.1 - Unreleased
HADOOP-6139. Fix the FsShell help messages for rm and rmr. (Jakob Homan HADOOP-6139. Fix the FsShell help messages for rm and rmr. (Jakob Homan
via szetszwo) via szetszwo)
HADOOP-6145. Fix FsShell rm/rmr error messages when there is a FNFE.
(Jakob Homan via szetszwo)
Release 0.20.0 - 2009-04-15 Release 0.20.0 - 2009-04-15
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1110,7 +1110,16 @@ void process(Path p, FileSystem srcFs) throws IOException {
/* delete a file */ /* delete a file */
private void delete(Path src, FileSystem srcFs, boolean recursive, private void delete(Path src, FileSystem srcFs, boolean recursive,
boolean skipTrash) throws IOException { boolean skipTrash) throws IOException {
if (srcFs.isDirectory(src) && !recursive) { FileStatus fs = null;
try {
fs = srcFs.getFileStatus(src);
} catch (FileNotFoundException fnfe) {
// Have to re-throw so that console output is as expected
throw new FileNotFoundException("cannot remove "
+ src + ": No such file or directory.");
}
if (fs.isDir() && !recursive) {
throw new IOException("Cannot remove directory \"" + src + throw new IOException("Cannot remove directory \"" + src +
"\", use -rmr instead"); "\", use -rmr instead");
} }
@ -1126,10 +1135,6 @@ private void delete(Path src, FileSystem srcFs, boolean recursive,
if (srcFs.delete(src, true)) { if (srcFs.delete(src, true)) {
System.out.println("Deleted " + src); System.out.println("Deleted " + src);
} else { } else {
if (!srcFs.exists(src)) {
throw new FileNotFoundException("cannot remove "
+ src + ": No such file or directory.");
}
throw new IOException("Delete failed " + src); throw new IOException("Delete failed " + src);
} }
} }