knightcrawler-stremio / knightcrawler

A selfhosted Stremio addon
Apache License 2.0
223 stars 39 forks source link

INNER JOIN when selecting files and torrents to avoid null results #207

Closed funkypenguin closed 2 months ago

funkypenguin commented 2 months ago

After recent parser changes (which presumably discard some torrents after files end up in the files table), I found my addon erroring on certain IMDB queries.

It turns out the sequelize query which assembles the stream results performs a LEFT OUTER JOIN between the files table and the torrents table. Consequently, if theres' an infoHash in the files table which doesn't exist in the torrents table, the query will return NULL for all of the torrent fields, including seeders, title, etc.

I'm not sure why this happened, but it seems safer to use an INNER JOIN, such that only data which exists in both the files and torrents table is returned.

This PR simply effects this change, such that null results are no longer returned, and the addon doesn't error.