Skip to content

[FIX] Make sure game is available before auto updating #2979

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
StatusPromise,
GamepadInputEvent,
WineCommandArgs,
ExecResult
ExecResult,
Runner
} from 'common/types'
import * as path from 'path'
import {
Expand Down Expand Up @@ -629,7 +630,8 @@ ipcMain.handle('runWineCommand', async (e, args) => runWineCommand(args))
ipcMain.handle('checkGameUpdates', async (): Promise<string[]> => {
let oldGames: string[] = []
const { autoUpdateGames } = GlobalConfig.get().getSettings()
for (const runner in libraryManagerMap) {
let runner: Runner = 'sideload'
for (runner in libraryManagerMap) {
let gamesToUpdate = await libraryManagerMap[runner].listUpdateableGames()
if (autoUpdateGames) {
gamesToUpdate = autoUpdate(runner, gamesToUpdate)
Expand Down
11 changes: 6 additions & 5 deletions src/backend/storeManagers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { GameManager, LibraryManager } from 'common/types/game_manager'
import { logInfo, RunnerToLogPrefixMap } from 'backend/logger/logger'

import { addToQueue } from 'backend/downloadmanager/downloadqueue'
import { DMQueueElement, GameInfo } from 'common/types'
import { DMQueueElement, GameInfo, Runner } from 'common/types'
import { isGameAvailable } from 'backend/api/helpers'
interface GameManagerMap {
[key: string]: GameManager
}
Expand All @@ -24,8 +25,8 @@ export const gameManagerMap: GameManagerMap = {
nile: NileGameManager
}

interface LibraryManagerMap {
[key: string]: LibraryManager
type LibraryManagerMap = {
[key in Runner]: LibraryManager
}

export const libraryManagerMap: LibraryManagerMap = {
Expand Down Expand Up @@ -56,14 +57,14 @@ function getDMElement(gameInfo: GameInfo, appName: string) {
return dmQueueElement
}

export function autoUpdate(runner: string, gamesToUpdate: string[]) {
export function autoUpdate(runner: Runner, gamesToUpdate: string[]) {
const logPrefix = RunnerToLogPrefixMap[runner]
gamesToUpdate.forEach(async (appName) => {
const { ignoreGameUpdates } = await gameManagerMap[runner].getSettings(
appName
)
const gameInfo = gameManagerMap[runner].getGameInfo(appName)
if (!ignoreGameUpdates) {
if (!ignoreGameUpdates && (await isGameAvailable({ appName, runner }))) {
logInfo(`Auto-Updating ${gameInfo.title}`, logPrefix)
const dmQueueElement: DMQueueElement = getDMElement(gameInfo, appName)
addToQueue(dmQueueElement)
Expand Down