Fix broken download of directories
(cherry picked from commit 745c9a01243b8eefc72d89d1164d7d010b80983b)
This commit is contained in:
parent
e76faebc95
commit
b31b4bf029
@ -1,4 +1,4 @@
|
|||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
@ -28,6 +28,7 @@
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate;
|
import org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate;
|
||||||
@ -389,17 +390,22 @@ public Path run() throws Exception {
|
|||||||
*/
|
*/
|
||||||
private void changePermissions(FileSystem fs, final Path path)
|
private void changePermissions(FileSystem fs, final Path path)
|
||||||
throws IOException, InterruptedException {
|
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;
|
FsPermission perm = cachePerms;
|
||||||
// set public perms as 755 or 555 based on dir or file
|
// set public perms as 755 or 555 based on dir or file
|
||||||
if (resource.getVisibility() == LocalResourceVisibility.PUBLIC) {
|
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
|
// set private perms as 700 or 500
|
||||||
else {
|
else {
|
||||||
// PRIVATE:
|
// PRIVATE:
|
||||||
// APPLICATION:
|
// 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
|
LOG.debug("Changing permissions for path " + path
|
||||||
+ " to perm " + perm);
|
+ " to perm " + perm);
|
||||||
@ -415,8 +421,7 @@ public Void run() throws Exception {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (fStatus.isDirectory()
|
if (isDir) {
|
||||||
&& !fStatus.isSymlink()) {
|
|
||||||
FileStatus[] statuses = fs.listStatus(path);
|
FileStatus[] statuses = fs.listStatus(path);
|
||||||
for (FileStatus status : statuses) {
|
for (FileStatus status : statuses) {
|
||||||
changePermissions(fs, status.getPath());
|
changePermissions(fs, status.getPath());
|
||||||
|
Loading…
Reference in New Issue
Block a user