diff --git a/airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java b/airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java index 298d7a2f..d9c13a10 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java +++ b/airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java @@ -154,7 +154,7 @@ public class CoverArtService { } private boolean isMediaFile(File file) { - return !mediaFileService.filterMediaFiles(new File[]{file}).isEmpty(); + return mediaFileService.includeMediaFile(file); } private void backup(File newCoverFile, File backup) { diff --git a/airsonic-main/src/main/java/org/airsonic/player/service/MediaFileService.java b/airsonic-main/src/main/java/org/airsonic/player/service/MediaFileService.java index b8c93d4d..1298fabb 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/service/MediaFileService.java +++ b/airsonic-main/src/main/java/org/airsonic/player/service/MediaFileService.java @@ -193,10 +193,10 @@ public class MediaFileService { List result = new ArrayList(); for (MediaFile child : mediaFileDao.getChildrenOf(parent.getPath())) { child = checkLastModified(child, useFastCache); - if (child.isDirectory() && includeDirectories) { + if (child.isDirectory() && includeDirectories && includeMediaFile(child)) { result.add(child); } - if (child.isFile() && includeFiles) { + if (child.isFile() && includeFiles && includeMediaFile(child)) { result.add(child); } } @@ -406,11 +406,22 @@ public class MediaFileService { mediaFileDao.createOrUpdateMediaFile(parent); } + public boolean includeMediaFile(MediaFile candidate) { + return includeMediaFile(candidate.getFile()); + } + + public boolean includeMediaFile(File candidate) { + String suffix = FilenameUtils.getExtension(candidate.getName()).toLowerCase(); + if (!isExcluded(candidate) && (FileUtil.isDirectory(candidate) || isAudioFile(suffix) || isVideoFile(suffix))) { + return true; + } + return false; + } + public List filterMediaFiles(File[] candidates) { List result = new ArrayList(); for (File candidate : candidates) { - String suffix = FilenameUtils.getExtension(candidate.getName()).toLowerCase(); - if (!isExcluded(candidate) && (FileUtil.isDirectory(candidate) || isAudioFile(suffix) || isVideoFile(suffix))) { + if (includeMediaFile(candidate)) { result.add(candidate); } }