-
Notifications
You must be signed in to change notification settings - Fork 247
Replace "preloader fix" with Steam game installation validation #1542
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c705e1a
Rename PreloadFixer to SteamInstallationValidator
anttimaki 4ae2995
Empty the whole game folder when validating steam game files
anttimaki f877b70
Update references to preloader fix
anttimaki 26ba72f
Fix error message which assumes all games have multiple executables
anttimaki 2bf9148
Remove references to an unused variable in Manager.vue
anttimaki 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
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,64 @@ | ||
| import GameDirectoryResolverProvider from '../../providers/ror2/game/GameDirectoryResolverProvider'; | ||
| import R2Error from '../../model/errors/R2Error'; | ||
| import * as path from 'path'; | ||
| import FsProvider from '../../providers/generic/file/FsProvider'; | ||
| import ManagerInformation from '../../_managerinf/ManagerInformation'; | ||
| import LinkProvider from '../../providers/components/LinkProvider'; | ||
| import FileUtils from '../../utils/FileUtils'; | ||
| import Game from '../../model/game/Game'; | ||
| import { StorePlatform } from '../../model/game/StorePlatform'; | ||
|
|
||
|
|
||
| export class SteamInstallationValidator { | ||
|
|
||
| public static async validateInstallation(game: Game): Promise<R2Error | void> { | ||
| if (![StorePlatform.STEAM, StorePlatform.STEAM_DIRECT].includes(game.activePlatform.storePlatform)) { | ||
| return new R2Error( | ||
| "This feature is not available on non-Steam platforms.", | ||
| "The feature deletes the contents of the game folder and verifies files. You can do the same manually." | ||
| ); | ||
| } | ||
|
|
||
| const gameFolder = await GameDirectoryResolverProvider.instance.getDirectory(game); | ||
| if (gameFolder instanceof R2Error) { | ||
| return gameFolder; | ||
| } | ||
|
|
||
| // Sanity check we're about to delete something resembling a valid game folder. | ||
| let exeFound = false; | ||
| for (let exeName of game.exeName) { | ||
| if (await FsProvider.instance.exists(path.join(gameFolder, exeName))) { | ||
| exeFound = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (!exeFound) { | ||
| const message = game.exeName.length > 1 ? | ||
| `Could not find any of "${game.exeName.join('", "')}"` : | ||
| `Could not find "${game.exeName[0]}"`; | ||
|
|
||
| return new R2Error( | ||
| `${game.displayName} folder is invalid`, | ||
| message, | ||
| `Set the ${game.displayName} folder in the settings section` | ||
| ); | ||
| } | ||
|
|
||
| try { | ||
| await FileUtils.emptyDirectory(gameFolder); | ||
| } catch(e) { | ||
| return R2Error.fromThrownValue( | ||
| e, | ||
| 'Failed to empty the game folder', | ||
| `Try launching ${ManagerInformation.APP_NAME} as an administrator` | ||
| ); | ||
| } | ||
|
|
||
| try { | ||
| LinkProvider.instance.openLink(`steam://validate/${game.activePlatform.storeIdentifier}`); | ||
| } catch(e) { | ||
| return R2Error.fromThrownValue(e, 'Failed to start steam://validate'); | ||
| } | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.