From 41967e76dfc2435382a9ef4adb84ef25de2832bc Mon Sep 17 00:00:00 2001 From: Evan Harris Date: Wed, 11 Sep 2019 16:42:27 -0500 Subject: [PATCH] Media file scan will now heed configured music/video file types It will also now heed the Media Folders -> Exclude Pattern. Fixes #1227. Signed-off-by: Andrew DeMaria --- .../airsonic/player/ajax/CoverArtService.java | 2 +- .../player/service/MediaFileService.java | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) 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); } }