-
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
e92dfa1
d419ccf
00c2b0e
378fae9
9b9c1e9
6b36862
c5171c3
ba07ca7
683131e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 })) | ||||||||||||||
|
Comment on lines
+13
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The filter here does not exclude games with |
||||||||||||||
| ); | ||||||||||||||
|
|
||||||||||||||
| 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, total: gamesToCheck.length }; | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| registerEvent( | ||||||||||||||
| "removeUninstalledGameExecutables", | ||||||||||||||
| removeUninstalledGameExecutables | ||||||||||||||
| ); | ||||||||||||||
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.
totalseems to be the number of games checked, not the number of uninstalled executables, soremoved {{removed}} of {{total}} uninstalled game executablescan sound like all checked games were uninstalled.could you please adjust this text to something like
removed {{removed}} stale executable paths from {{total}} checked gamesor simplyremoved {{removed}} stale executable paths?