From 627abb1cedfd2036c415573024210e662cf23b75 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 13 Apr 2016 11:21:55 +0000 Subject: [PATCH] Improved getVolumeRoots --- source/net/filebot/media/ReleaseInfo.java | 26 ++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/source/net/filebot/media/ReleaseInfo.java b/source/net/filebot/media/ReleaseInfo.java index dc25c29c..cbd3ab19 100644 --- a/source/net/filebot/media/ReleaseInfo.java +++ b/source/net/filebot/media/ReleaseInfo.java @@ -7,6 +7,7 @@ import static java.util.Collections.*; import static java.util.ResourceBundle.*; import static java.util.regex.Pattern.*; import static java.util.stream.Collectors.*; +import static net.filebot.Settings.*; import static net.filebot.similarity.Normalization.*; import static net.filebot.util.FileUtilities.*; import static net.filebot.util.RegularExpressions.*; @@ -44,6 +45,7 @@ import org.tukaani.xz.XZInputStream; import net.filebot.Cache; import net.filebot.CacheType; import net.filebot.Resource; +import net.filebot.Settings.ApplicationFolder; import net.filebot.util.FileUtilities.RegexFileFilter; import net.filebot.util.SystemProperty; import net.filebot.web.Movie; @@ -219,28 +221,32 @@ public class ReleaseInfo { Set volumes = new HashSet(); // user root folder - volumes.add(new File(System.getProperty("user.home"))); + volumes.add(ApplicationFolder.UserHome.get()); // Windows / Linux / Mac system roots volumes.addAll(getFileSystemRoots()); + // Linux / Mac if (File.separator.equals("/")) { // Linux and Mac system root folders - for (File root : getFileSystemRoots()) { - volumes.addAll(getChildren(root, FOLDERS)); + for (File userFolder : volumes.toArray(new File[0])) { + volumes.addAll(getChildren(userFolder, FOLDERS)); } - // user-specific media roots - String username = System.getProperty("user.name", "anonymous"); - for (File mediaRoot : getMediaRoots()) { volumes.addAll(getChildren(mediaRoot, FOLDERS)); volumes.add(mediaRoot); + } + } - // add additional user roots if user.home is not set properly or listFiles doesn't work - File userRoot = new File(mediaRoot, username); - volumes.add(userRoot); - volumes.add(new File(userRoot, "Movies")); // ignore default Movie folder on Mac + // Mac + if (isMacSandbox()) { + File realUserHome = ApplicationFolder.UserHome.get(); + File sandboxUserHome = new File(System.getProperty("user.home")); + + // e.g. ignore default Movie folder on Mac + for (File userFolder : getChildren(sandboxUserHome, FOLDERS)) { + volumes.add(new File(realUserHome, userFolder.getName())); } }