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 <lostonamountain@gmail.com>
master
Evan Harris 5 years ago committed by Andrew DeMaria
parent 1b28d2c2fe
commit 41967e76df
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 2
      airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java
  2. 19
      airsonic-main/src/main/java/org/airsonic/player/service/MediaFileService.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) {

@ -193,10 +193,10 @@ public class MediaFileService {
List<MediaFile> result = new ArrayList<MediaFile>();
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<File> filterMediaFiles(File[] candidates) {
List<File> result = new ArrayList<File>();
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);
}
}

Loading…
Cancel
Save