Merge pull request #6537 from jbroadus/scan-sanity-check

Prevent runaway cover art searches.
This commit is contained in:
John Maguire 2020-01-19 17:12:13 +00:00 committed by GitHub
commit d15777ea15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,6 +48,8 @@ static const char *kNoMediaFile = ".nomedia";
static const char *kNoMusicFile = ".nomusic";
}
static const int kUnfilteredImageLimit = 10;
QStringList LibraryWatcher::sValidImages;
const char* LibraryWatcher::kSettingsGroup = "LibraryWatcher";
@ -717,6 +719,15 @@ QString LibraryWatcher::PickBestImage(const QStringList& images) {
}
if (filtered.isEmpty()) {
// If we're scanning a device, we may hit a directory that contains
// multiple types of media. An example is a camera directory on a smart
// phone that contains JPG and MP4. We don't want to cycle through hundreds
// of images for each audio file found, so we've set a threshold to try to
// detect this case.
if (images.count() > kUnfilteredImageLimit) {
return "";
}
// the filter was too restrictive, just use the original list
filtered = images;
}