Skip to content

Commit

Permalink
[FIX] Make sure game is available before auto updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Etaash-mathamsetty committed Aug 10, 2023
1 parent b622830 commit 27d9bf4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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

0 comments on commit 27d9bf4

Please sign in to comment.