Avoid directory listing of folders that can't accessible due to the sandbox anyway

This commit is contained in:
Reinhard Pointner 2018-04-16 14:18:52 +07:00
parent 75d0e86e8c
commit 75a5cc55af
2 changed files with 20 additions and 13 deletions

View File

@ -14,7 +14,7 @@ import java.util.logging.Level;
public enum ApplicationFolder {
// real user home (the user.home will point to the application-specific container in sandbox environments)
UserHome(isMacSandbox() ? System.getProperty("UserHome") : System.getProperty("user.home")),
UserHome(System.getProperty(isMacSandbox() ? "UserHome" : "user.home")),
AppData(System.getProperty("application.dir", UserHome.resolve(".filebot").getPath())),

View File

@ -223,26 +223,33 @@ public class ReleaseInfo {
// Windows / Linux / Mac system roots
volumes.addAll(roots);
// Linux / Mac
if (File.separator.equals("/")) {
// Linux and Mac system root folders
for (File root : roots) {
volumes.addAll(getChildren(root, FOLDERS));
}
if (isMacSandbox()) {
// Mac
for (File mediaRoot : getMediaRoots()) {
volumes.addAll(getChildren(mediaRoot, FOLDERS));
volumes.add(mediaRoot);
}
}
// Mac
if (isMacSandbox()) {
// e.g. ignore default Movie folder (user.home and real user home are different in the sandbox environment)
for (File userFolder : getChildren(new File(System.getProperty("user.home")), FOLDERS)) {
File sandbox = new File(System.getProperty("user.home"));
for (File userFolder : getChildren(sandbox, FOLDERS)) {
volumes.add(new File(home, userFolder.getName()));
}
} else {
// Linux / Mac
if (!isWindowsApp()) {
// Linux and Mac system root folders
for (File root : roots) {
volumes.addAll(getChildren(root, FOLDERS));
}
for (File mediaRoot : getMediaRoots()) {
volumes.addAll(getChildren(mediaRoot, FOLDERS));
volumes.add(mediaRoot);
}
}
// Windows / Linux
volumes.addAll(getChildren(home, FOLDERS));
}