hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject hadoop git commit: Fix broken download of directories
Date Mon, 10 Nov 2014 23:33:28 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2.5 8b0ed31a7 -> 21d4fca8b


Fix broken download of directories

(cherry picked from commit 745c9a01243b8eefc72d89d1164d7d010b80983b)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/21d4fca8
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/21d4fca8
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/21d4fca8

Branch: refs/heads/branch-2.5
Commit: 21d4fca8b6b6064a813806d655107c1f7eff58c3
Parents: 8b0ed31
Author: Karthik Kambatla <kasha@apache.org>
Authored: Wed Nov 5 10:12:56 2014 -0800
Committer: Karthik Kambatla <kasha@apache.org>
Committed: Mon Nov 10 15:33:20 2014 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/yarn/util/FSDownload.java    | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/21d4fca8/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java
index 8cc5ed3..514632a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/FSDownload.java
@@ -1,4 +1,4 @@
-/**
+ /**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
@@ -28,6 +28,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.regex.Pattern;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate;
@@ -392,17 +393,22 @@ public class FSDownload implements Callable<Path> {
    */
   private void changePermissions(FileSystem fs, final Path path)
       throws IOException, InterruptedException {
-    FileStatus fStatus = fs.getFileStatus(path);
+    File f = new File(path.toUri());
+    if (FileUtils.isSymlink(f)) {
+      // avoid following symlinks when changing permissions
+      return;
+    }
+    boolean isDir = f.isDirectory();
     FsPermission perm = cachePerms;
     // set public perms as 755 or 555 based on dir or file
     if (resource.getVisibility() == LocalResourceVisibility.PUBLIC) {
-      perm = fStatus.isDirectory() ? PUBLIC_DIR_PERMS : PUBLIC_FILE_PERMS;
+      perm = isDir ? PUBLIC_DIR_PERMS : PUBLIC_FILE_PERMS;
     }
     // set private perms as 700 or 500
     else {
       // PRIVATE:
       // APPLICATION:
-      perm = fStatus.isDirectory() ? PRIVATE_DIR_PERMS : PRIVATE_FILE_PERMS;
+      perm = isDir ? PRIVATE_DIR_PERMS : PRIVATE_FILE_PERMS;
     }
     LOG.debug("Changing permissions for path " + path
         + " to perm " + perm);
@@ -418,8 +424,7 @@ public class FSDownload implements Callable<Path> {
         }
       });
     }
-    if (fStatus.isDirectory()
-        && !fStatus.isSymlink()) {
+    if (isDir) {
       FileStatus[] statuses = fs.listStatus(path);
       for (FileStatus status : statuses) {
         changePermissions(fs, status.getPath());


Mime
View raw message