Skip to content

Commit

Permalink
Remove fixes file when a game is uninstalled (#3398)
Browse files Browse the repository at this point in the history
Remove fixes file when the game uninstalled
  • Loading branch information
arielj authored Jan 6, 2024
1 parent d5d1482 commit 44ea197
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
11 changes: 3 additions & 8 deletions src/backend/downloadmanager/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { fixesPath } from 'backend/constants'
import path from 'path'
import { existsSync, mkdirSync } from 'graceful-fs'
import { platform } from 'os'
import { storeMap } from 'common/utils'

async function installQueueElement(params: InstallParams): Promise<{
status: DMStatus
Expand Down Expand Up @@ -169,15 +170,9 @@ async function updateQueueElement(params: InstallParams): Promise<{
}
}

const runnerToStore = {
legendary: 'epic',
gog: 'gog',
nile: 'amazon'
}

async function downloadFixesFor(appName: string, runner: Runner) {
const url = `https://raw.githubusercontent.com/Heroic-Games-Launcher/known-fixes/main/${appName}-${runnerToStore[runner]}.json`
const dest = path.join(fixesPath, `${appName}-${runnerToStore[runner]}.json`)
const url = `https://raw.githubusercontent.com/Heroic-Games-Launcher/known-fixes/main/${appName}-${storeMap[runner]}.json`
const dest = path.join(fixesPath, `${appName}-${storeMap[runner]}.json`)
if (!existsSync(fixesPath)) {
mkdirSync(fixesPath, { recursive: true })
}
Expand Down
9 changes: 2 additions & 7 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import {
deleteAbortController
} from './utils/aborthandler/aborthandler'
import { download, isInstalled } from './wine/runtimes/runtimes'
import { storeMap } from 'common/utils'

async function prepareLaunch(
gameSettings: GameSettings,
Expand Down Expand Up @@ -389,14 +390,8 @@ async function prepareWineLaunch(
return { success: true, envVars: envVars }
}

const runnerToStore = {
legendary: 'epic',
gog: 'gog',
nile: 'amazon'
}

async function installFixes(appName: string, runner: Runner) {
const fixPath = join(fixesPath, `${appName}-${runnerToStore[runner]}.json`)
const fixPath = join(fixesPath, `${appName}-${storeMap[runner]}.json`)

if (!existsSync(fixPath)) return

Expand Down
12 changes: 11 additions & 1 deletion src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ import {
customThemesWikiLink,
createNecessaryFolders,
fixAsarPath,
isSnap
isSnap,
fixesPath
} from './constants'
import { handleProtocol } from './protocol'
import {
Expand Down Expand Up @@ -151,6 +152,7 @@ import {
getGameSdl
} from 'backend/storeManagers/legendary/library'
import { formatSystemInfo, getSystemInfo } from './utils/systeminfo'
import { storeMap } from 'common/utils'

app.commandLine?.appendSwitch('ozone-platform-hint', 'auto')

Expand Down Expand Up @@ -1239,6 +1241,14 @@ ipcMain.handle(
removeIfExists(appName.concat('-lastPlay.log'))
}

const fixFilePath = path.join(
fixesPath,
`${appName}-${storeMap[runner]}.json`
)
if (existsSync(fixFilePath)) {
rmSync(fixFilePath)
}

notify({ title, body: i18next.t('notify.uninstalled') })
logInfo('Finished uninstalling', LogPrefix.Backend)
}
Expand Down
7 changes: 1 addition & 6 deletions src/backend/wiki_game_info/gamesdb/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GamesDBInfo, Runner } from 'common/types'
import { logInfo, LogPrefix } from 'backend/logger/logger'
import { GamesDBData } from 'common/types/gog'
import { getGamesdbData } from 'backend/storeManagers/gog/library'
import { storeMap } from 'common/utils'

export async function getInfoFromGamesDB(
title: string,
Expand All @@ -10,12 +11,6 @@ export async function getInfoFromGamesDB(
): Promise<GamesDBInfo | null> {
logInfo(`Getting GamesDB data for ${title}`, LogPrefix.ExtraGameInfo)

const storeMap: { [key in Runner]: string | undefined } = {
legendary: 'epic',
gog: 'gog',
nile: 'amazon',
sideload: undefined
}
const storeName = storeMap[runner]
if (!storeName) {
return { steamID: '' }
Expand Down
8 changes: 8 additions & 0 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Runner } from './types'

export const storeMap: { [key in Runner]: string | undefined } = {
legendary: 'epic',
gog: 'gog',
nile: 'amazon',
sideload: undefined
}

0 comments on commit 44ea197

Please sign in to comment.