From 5391bdd810d6aca1c69e3359dcbc575ae294d093 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 6 Jan 2014 18:15:37 +0000 Subject: [PATCH] * bug fix for when listFiles returns null for folders due to permission issues --- .../filebot/media/ReleaseInfo.java | 27 ++++++++++++++----- .../filebot/media/ReleaseInfo.properties | 3 +++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/source/net/sourceforge/filebot/media/ReleaseInfo.java b/source/net/sourceforge/filebot/media/ReleaseInfo.java index 02a3ad0e..fefc5bc1 100644 --- a/source/net/sourceforge/filebot/media/ReleaseInfo.java +++ b/source/net/sourceforge/filebot/media/ReleaseInfo.java @@ -180,19 +180,26 @@ public class ReleaseInfo { // Windows / Linux / Mac system roots addAll(volumes, File.listRoots()); - // media root folders if (File.separator.equals("/")) { - // Linux and Mac + // Linux and Mac system root folders 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()) { - addAll(volumes, root.listFiles(FOLDERS)); + File[] f = root.listFiles(FOLDERS); + if (f != null) { + addAll(volumes, f); + } } } } + volumeRoots = unmodifiableSet(volumes); } 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 } + public List getMediaRoots() { + List roots = new ArrayList(); + 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 protected final CachedResource releaseGroupResource = new PatternResource(getBundle(getClass().getName()).getString("url.release-groups")); protected final CachedResource queryBlacklistResource = new PatternResource(getBundle(getClass().getName()).getString("url.query-blacklist")); diff --git a/source/net/sourceforge/filebot/media/ReleaseInfo.properties b/source/net/sourceforge/filebot/media/ReleaseInfo.properties index 771532f7..6d9c9840 100644 --- a/source/net/sourceforge/filebot/media/ReleaseInfo.properties +++ b/source/net/sourceforge/filebot/media/ReleaseInfo.properties @@ -30,3 +30,6 @@ url.anidb-index: http://filebot.net/data/anidb.txt.xz # disk folder matcher pattern.diskfolder.entry: BDMV|HVDVD_TS|VIDEO_TS|AUDIO_TS|VCD|movie.nfo + +# media root folders +folder.media.roots: /Volumes:/home:/mnt:/media:/share \ No newline at end of file