-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat: Sync library executable state during installed games scan #2328
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
Open
IsaiahBideshi
wants to merge
9
commits into
hydralauncher:main
Choose a base branch
from
IsaiahBideshi:fix-clear-stale-executable-paths
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+149
−17
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e92dfa1
feat: Sync library executable state during installed games scan
IsaiahBideshi d419ccf
fix: executable cleanup feedback
IsaiahBideshi 00c2b0e
Merge branch 'hydralauncher:main' into fix-clear-stale-executable-paths
IsaiahBideshi 378fae9
fix: scan excludes stale game executables -> clear paths before scan.
IsaiahBideshi 9b9c1e9
Merge branch 'main' into fix-clear-stale-executable-paths
IsaiahBideshi 6b36862
fix: disable scan options and remove scan button while syncing
IsaiahBideshi c5171c3
Merge branch 'fix-clear-stale-executable-paths' of https://github.com…
IsaiahBideshi ba07ca7
Merge branch 'main' into fix-clear-stale-executable-paths
IsaiahBideshi 683131e
removed total from output, sonar fixes.
IsaiahBideshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/events/library/remove-uninstalled-game-executables.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import fs from "node:fs"; | ||
| import { registerEvent } from "../register-event"; | ||
| import { updateGameExecutablePath } from "@main/helpers/update-executable-path"; | ||
| import { gamesSublevel } from "@main/level"; | ||
| import { logger, WindowManager } from "@main/services"; | ||
|
|
||
| interface RemovedGame { | ||
| title: string; | ||
| } | ||
|
|
||
| const removeUninstalledGameExecutables = async () => { | ||
| const games = await gamesSublevel | ||
| .iterator() | ||
| .all() | ||
| .then((results) => | ||
| results | ||
| .filter( | ||
| ([_key, game]) => game.isDeleted === false && game.shop !== "custom" | ||
| ) | ||
| .map(([key, game]) => ({ key, game })) | ||
| ); | ||
|
|
||
| const removedGames: RemovedGame[] = []; | ||
| const gamesToCheck = games.filter((g) => g.game.executablePath); | ||
|
|
||
| for (const { key, game } of gamesToCheck) { | ||
| const exePath = game.executablePath!; | ||
| if (!fs.existsSync(exePath)) { | ||
| await gamesSublevel.put(key, { | ||
| ...updateGameExecutablePath(game, null), | ||
| installedSizeInBytes: null, | ||
| automaticCloudSync: false, | ||
| }); | ||
|
|
||
| logger.info( | ||
| `[RemoveUninstalledGameExecutables] Removed executable for ${game.objectId}: ${exePath}` | ||
| ); | ||
| removedGames.push({ title: game.title }); | ||
| } | ||
| } | ||
|
|
||
| if (removedGames.length > 0) { | ||
| WindowManager.sendToAppWindows("on-library-batch-complete"); | ||
| } | ||
| return { removedGames: removedGames }; | ||
| }; | ||
|
|
||
| registerEvent( | ||
| "removeUninstalledGameExecutables", | ||
| removeUninstalledGameExecutables | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filter here does not exclude games with
shop === "custom", butscanInstalledGamesexplicitly does (game.isDeleted === false && game.shop !== "custom"). This inconsistency means the removal step will clear executable paths for custom (manually-added) games that the scan never touched, silently breaking those library entries for users who have manually configured them.