Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix Empty Array Reduce #1494

Merged
merged 4 commits into from
Oct 7, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/renderer/lib/torrent-poster.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ function scoreAudioCoverFile (imgFile) {
function torrentPosterFromAudio (torrent, cb) {
const imageFiles = filterOnExtension(torrent, mediaExtensions.image)

if (imageFiles.length === 0) return cb(new Error('Generated poster contains no files'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this routine is to find a suitable image to be used as a poster. So without files, there is no poster. Error message maybe something like "could not find a suitable image to generate an audio poster".

mathiasvr marked this conversation as resolved.
Show resolved Hide resolved

const bestCover = imageFiles.map(file => {
return {
file: file,
Expand All @@ -129,8 +131,6 @@ function torrentPosterFromAudio (torrent, cb) {
return b
})

if (!bestCover) return cb(new Error('Generated poster contains no data'))

const extname = path.extname(bestCover.file.name)
bestCover.file.getBuffer((err, buf) => cb(err, buf, extname))
}
Expand Down