Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 1 addition & 15 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import 'backend/updater'
import { autoUpdater } from 'electron-updater'
import { cpus } from 'os'
import { existsSync, watch, readdirSync, readFileSync } from 'graceful-fs'
import { existsSync, readdirSync, readFileSync } from 'graceful-fs'
import 'source-map-support/register'

import Backend from 'i18next-fs-backend'
Expand Down Expand Up @@ -132,7 +132,6 @@ import {
wikiLink,
wineprefixFAQ
} from './constants/urls'
import { legendaryInstalled } from './storeManagers/legendary/constants'
import {
isCLIFullscreen,
isCLINoGui,
Expand Down Expand Up @@ -864,19 +863,6 @@ addListener('setSetting', (event, { appName, key, value }) => {
}
})

// Watch the installed games file and trigger a refresh on the installed games if something changes
if (existsSync(legendaryInstalled)) {
let watchTimeout: NodeJS.Timeout | undefined
watch(legendaryInstalled, () => {
logInfo('installed.json updated, refreshing library', LogPrefix.Legendary)
// `watch` might fire twice (while Legendary/we are still writing chunks of the file), which would in turn make LegendaryLibrary fail to
// decode the JSON data. So instead of immediately calling LegendaryLibrary.get().refreshInstalled(), call it only after no writes happen
// in a 500ms timespan
if (watchTimeout) clearTimeout(watchTimeout)
watchTimeout = setTimeout(LegendaryLibraryManager.refreshInstalled, 500)
})
}

addHandler('refreshLibrary', async (e, library?) => {
if (library !== undefined && library !== 'all') {
await libraryManagerMap[library].refresh()
Expand Down
5 changes: 4 additions & 1 deletion src/backend/storeManagers/legendary/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
listUpdateableGames,
getGameInfo as getLegLibraryGameInfo,
changeGameInstallPath,
installState
installState,
refreshInstalled
} from './library'
import { LegendaryUser } from './user'
import {
Expand Down Expand Up @@ -662,6 +663,8 @@ export async function install(
}
addShortcuts(appName)

refreshInstalled()

return { status: 'done' }
}

Expand Down
Loading