Skip to content

Bug Fix Empty Array Reduce - #1494

Merged
Borewit merged 4 commits into
webtorrent:masterfrom
clujin:fix_empty_array_reduce
Oct 7, 2018
Merged

Borewit merged 4 commits into
webtorrent:masterfrom
clujin:fix_empty_array_reduce

Conversation

@clujin

@clujin clujin commented Oct 7, 2018

Copy link
Copy Markdown
Contributor

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

welcome Bot commented Oct 7, 2018

Copy link
Copy Markdown

🙌 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
Comment thread src/renderer/lib/torrent-poster.js Outdated

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

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

Copy link
Copy Markdown
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?

@Borewit Borewit left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/renderer/lib/torrent-poster.js Outdated
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
Copy Markdown
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

welcome Bot commented Oct 7, 2018

Copy link
Copy Markdown

🎉 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