fix when bootstrapper present but update isn't

This commit is contained in:
ConfiG 2023-08-04 01:18:19 +03:00
parent cf3ed327e5
commit c2aacd9979
No known key found for this signature in database
GPG key ID: 44DA1983F524C11B
2 changed files with 22 additions and 16 deletions

View file

@ -108,8 +108,10 @@ int main(int argc, char* argv[]) {
updatesDir = geodeDir / "update";
resourcesDir = geodeDir / "resources";
if (std::filesystem::exists(geodeDir) && std::filesystem::exists(updatesDir)) {
if (std::filesystem::exists(workingDir / "GeodeBootstrapper.dll"))
removePath(workingDir / "GeodeBootstrapper.dll");
if (std::filesystem::exists(geodeDir) && std::filesystem::exists(updatesDir)) {
updateFile("XInput9_1_0.dll");
updateFile("Geode.dll");
updateResources();

View file

@ -13,23 +13,27 @@ void updateGeode() {
const auto geodeDir = dirs::getGeodeDir();
const auto updatesDir = geodeDir / "update";
// updater deletes the update folder so it's fine to not check if it's empty
if (ghc::filesystem::exists(geodeDir) && ghc::filesystem::exists(updatesDir)) {
// update updater
if (ghc::filesystem::exists(updatesDir / "GeodeUpdater.exe"))
ghc::filesystem::rename(updatesDir / "GeodeUpdater.exe", workingDir / "GeodeUpdater.exe");
bool bootstrapperExists = ghc::filesystem::exists(workingDir / "GeodeBootstrapper.dll");
bool updatesDirExists = ghc::filesystem::exists(geodeDir) && ghc::filesystem::exists(updatesDir);
wchar_t buffer[MAX_PATH];
GetModuleFileNameW(nullptr, buffer, MAX_PATH);
const auto gdName = ghc::filesystem::path(buffer).filename().string();
if (!bootstrapperExists && !updatesDirExists)
return;
// launch updater
const auto updaterPath = (workingDir / "GeodeUpdater.exe").string();
ShellExecuteA(nullptr, "open", updaterPath.c_str(), gdName.c_str(), workingDir.string().c_str(), false);
// update updater
if (ghc::filesystem::exists(updatesDir) &&
ghc::filesystem::exists(updatesDir / "GeodeUpdater.exe"))
ghc::filesystem::rename(updatesDir / "GeodeUpdater.exe", workingDir / "GeodeUpdater.exe");
// quit gd before it can even start
exit(0);
}
wchar_t buffer[MAX_PATH];
GetModuleFileNameW(nullptr, buffer, MAX_PATH);
const auto gdName = ghc::filesystem::path(buffer).filename().string();
// launch updater
const auto updaterPath = (workingDir / "GeodeUpdater.exe").string();
ShellExecuteA(nullptr, "open", updaterPath.c_str(), gdName.c_str(), workingDir.string().c_str(), false);
// quit gd before it can even start
exit(0);
}
int WINAPI gdMainHook(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) {
@ -113,4 +117,4 @@ BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID) {
return TRUE;
}
#endif
#endif