fix: edge case when season resolving would get stuck in an infinite loop

This commit is contained in:
ThaUnknown 2022-04-06 19:40:33 +02:00
parent 264b267f57
commit a0b1d4d60f
3 changed files with 6 additions and 12 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "Miru", "name": "Miru",
"version": "1.1.3", "version": "1.1.4",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>", "author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"main": "src/index.js", "main": "src/index.js",
"homepage": "https://github.com/ThaUnknown/miru#readme", "homepage": "https://github.com/ThaUnknown/miru#readme",

View file

@ -76,12 +76,6 @@ function createWindow () {
mainWindow.webContents.openDevTools() mainWindow.webContents.openDevTools()
} }
// Uncomment the following line of code when app is ready to be packaged.
// loadURL(mainWindow);
// Open the DevTools and also disable Electron Security Warning.
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true
// Emitted when the window is closed. // Emitted when the window is closed.
mainWindow.on('closed', () => { mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows // Dereference the window object, usually you would store windows

View file

@ -186,12 +186,12 @@ async function resolveSeason (opts) {
const rootHighest = (rootMedia.nextAiringEpisode?.episode || rootMedia.episodes) const rootHighest = (rootMedia.nextAiringEpisode?.episode || rootMedia.episodes)
const prequel = !increment && findEdge(media, 'PREQUEL')?.node const prequel = !increment && findEdge(media, 'PREQUEL', undefined, force)?.node
const sequel = !prequel && findEdge(media, 'SEQUEL')?.node const sequel = !prequel && (increment || increment == null) && findEdge(media, 'SEQUEL', undefined, force)?.node
const edge = prequel || sequel const edge = prequel || sequel
increment = !prequel increment = increment ?? !prequel
if (!prequel && !sequel) { if (!edge) {
const obj = { media, episode: episode - offset, offset, increment, rootMedia } const obj = { media, episode: episode - offset, offset, increment, rootMedia }
if (!force) { if (!force) {
console.warn('Error in parsing!', obj) console.warn('Error in parsing!', obj)
@ -210,7 +210,7 @@ async function resolveSeason (opts) {
const diff = episode - (highest + offset) const diff = episode - (highest + offset)
media = temp media = temp
offset += highest offset += highest
if (diff <= rootHighest) { if (!force && diff <= rootHighest) {
episode -= offset episode -= offset
if (sequel) rootMedia = temp if (sequel) rootMedia = temp
return { media, episode, offset, increment, rootMedia } return { media, episode, offset, increment, rootMedia }