* bug fix for when listFiles returns null for folders due to permission issues

This commit is contained in:
Reinhard Pointner 2014-01-06 18:15:37 +00:00
parent 7cb21d824a
commit 5391bdd810
2 changed files with 24 additions and 6 deletions

View File

@ -180,19 +180,26 @@ public class ReleaseInfo {
// Windows / Linux / Mac system roots // Windows / Linux / Mac system roots
addAll(volumes, File.listRoots()); addAll(volumes, File.listRoots());
// media root folders
if (File.separator.equals("/")) { if (File.separator.equals("/")) {
// Linux and Mac // Linux and Mac system root folders
for (File root : File.listRoots()) { for (File root : File.listRoots()) {
addAll(volumes, root.listFiles(FOLDERS)); File[] f = root.listFiles(FOLDERS);
if (f != null) {
addAll(volumes, f);
} }
for (String path : asList("/Volumes", "/home", "/media", "/mnt")) { }
File root = new File(path);
// user-specific media roots
for (File root : getMediaRoots()) {
if (root.isDirectory()) { if (root.isDirectory()) {
addAll(volumes, root.listFiles(FOLDERS)); File[] f = root.listFiles(FOLDERS);
if (f != null) {
addAll(volumes, f);
} }
} }
} }
}
volumeRoots = unmodifiableSet(volumes); volumeRoots = unmodifiableSet(volumes);
} }
return volumeRoots; return volumeRoots;
@ -299,6 +306,14 @@ public class ReleaseInfo {
return new ClutterFileFilter(getExcludePattern(), Long.parseLong(getBundle(getClass().getName()).getString("number.clutter.maxfilesize"))); // only files smaller than 250 MB may be considered clutter return new ClutterFileFilter(getExcludePattern(), Long.parseLong(getBundle(getClass().getName()).getString("number.clutter.maxfilesize"))); // only files smaller than 250 MB may be considered clutter
} }
public List<File> getMediaRoots() {
List<File> roots = new ArrayList<File>();
for (String it : getBundle(getClass().getName()).getString("folder.media.roots").split(":")) {
roots.add(new File(it));
}
return roots;
}
// fetch release group names online and try to update the data every other day // fetch release group names online and try to update the data every other day
protected final CachedResource<String[]> releaseGroupResource = new PatternResource(getBundle(getClass().getName()).getString("url.release-groups")); protected final CachedResource<String[]> releaseGroupResource = new PatternResource(getBundle(getClass().getName()).getString("url.release-groups"));
protected final CachedResource<String[]> queryBlacklistResource = new PatternResource(getBundle(getClass().getName()).getString("url.query-blacklist")); protected final CachedResource<String[]> queryBlacklistResource = new PatternResource(getBundle(getClass().getName()).getString("url.query-blacklist"));

View File

@ -30,3 +30,6 @@ url.anidb-index: http://filebot.net/data/anidb.txt.xz
# disk folder matcher # disk folder matcher
pattern.diskfolder.entry: BDMV|HVDVD_TS|VIDEO_TS|AUDIO_TS|VCD|movie.nfo pattern.diskfolder.entry: BDMV|HVDVD_TS|VIDEO_TS|AUDIO_TS|VCD|movie.nfo
# media root folders
folder.media.roots: /Volumes:/home:/mnt:/media:/share