Browse Source

Merge -r 740156:740157 to move the change log of HADOOP-5085 from main to branch 0.20.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@740158 13f79535-47bb-0310-9956-ffa450edef68
Hairong Kuang 16 years ago
parent
commit
d9b9c98eaf
2 changed files with 13 additions and 1 deletions
  1. 3 0
      CHANGES.txt
  2. 10 1
      src/core/org/apache/hadoop/fs/FsShell.java

+ 3 - 0
CHANGES.txt

@@ -588,6 +588,9 @@ Release 0.20.0 - Unreleased
     HADOOP-5139. Catch IllegalArgumentException during metrics registration
     in RPC.  (Hairong Kuang via szetszwo)
 
+    HADOOP-5085. Copying a file to local with Crc throws an exception.
+    (hairong)
+
 Release 0.19.1 - Unreleased
 
   IMPROVEMENTS

+ 10 - 1
src/core/org/apache/hadoop/fs/FsShell.java

@@ -170,7 +170,7 @@ public class FsShell extends Configured implements Tool {
       System.err.println("Usage: java FsShell " + GET_SHORT_USAGE);
       throw iae;
     }
-    final boolean copyCrc = cf.getOpt("crc");
+    boolean copyCrc = cf.getOpt("crc");
     final boolean verifyChecksum = !cf.getOpt("ignoreCrc");
 
     if (dststr.equals("-")) {
@@ -182,6 +182,11 @@ public class FsShell extends Configured implements Tool {
       File dst = new File(dststr);      
       Path srcpath = new Path(srcstr);
       FileSystem srcFS = getSrcFileSystem(srcpath, verifyChecksum);
+      if (copyCrc && !(srcFS instanceof ChecksumFileSystem)) {
+        System.err.println("-crc option is not valid when source file system " +
+            "does not have crc files. Automatically turn the option off.");
+        copyCrc = false;
+      }
       FileStatus[] srcs = srcFS.globStatus(srcpath);
       boolean dstIsDir = dst.isDirectory(); 
       if (srcs.length > 1 && !dstIsDir) {
@@ -250,6 +255,10 @@ public class FsShell extends Configured implements Tool {
       }
 
       if (copyCrc) {
+        if (!(srcFS instanceof ChecksumFileSystem)) {
+          throw new IOException("Source file system does not have crc files");
+        }
+        
         ChecksumFileSystem csfs = (ChecksumFileSystem) srcFS;
         File dstcs = FileSystem.getLocal(srcFS.getConf())
           .pathToFile(csfs.getChecksumFile(new Path(dst.getCanonicalPath())));