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

Bug Fix Empty Array Reduce #1494

merged 4 commits into from
Oct 7, 2018

Conversation

clujin
Copy link
Contributor

@clujin clujin commented Oct 7, 2018

Issue: #1436

This PR fixes a small Type Error where filterOnExtension might return an empty array which will be operated by a map and reduce function. This will cause the reduce function to print out the Type Error. The suggested fix is to check for the empty array and return an Error.

@welcome
Copy link

welcome bot commented Oct 7, 2018

🙌 Thanks for opening this pull request! You're awesome.

@clujin clujin changed the title Bug Fix Empty Array Reduce [#1436] Bug Fix Empty Array Reduce Oct 7, 2018
@Borewit Borewit self-assigned this Oct 7, 2018
@Borewit Borewit added the bug label Oct 7, 2018
@Borewit Borewit self-requested a review October 7, 2018 08:18
@@ -5,6 +5,8 @@ const path = require('path')

const mediaExtensions = require('./media-extensions')

const msgNoSuitablePoster = 'Cannot generate a poster from any files in the torrent'
Copy link
Contributor

Choose a reason for hiding this comment

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

Good call @Borewit, could you actually move this to /src/renderer/lib/errors.js?

Copy link
Member

@Borewit Borewit left a comment

Choose a reason for hiding this comment

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

Seems to handle audio torrents without a poster just fine now:
2018-10-07 no poster available

Thanks for improving WebTorrent @clujin.

@@ -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".

@Borewit Borewit merged commit fa7d917 into webtorrent:master Oct 7, 2018
@welcome
Copy link

welcome bot commented Oct 7, 2018

🎉 Congrats on getting your first pull request landed!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants