diff --git a/Updater/Installer.cpp b/Updater/Installer.cpp index 620a339..4cf3983 100644 --- a/Updater/Installer.cpp +++ b/Updater/Installer.cpp @@ -62,7 +62,7 @@ static void CreateUninstallEntryIfNeeded(std::wstring filename) setUninstallDword(L"NoRepair", 1); } -bool PerformInstallation() +bool PerformInstallation(bool updateServerAvaliable) { auto rootPath = GetRootPath(); @@ -78,9 +78,15 @@ bool PerformInstallation() CreateDirectory(installPath.c_str(), nullptr); } + std::string downloadUrl = API_URL DOWNLOAD; + if (!updateServerAvaliable) + { + downloadUrl = BACKUP_DOWNLOAD_URL; + } + SetWindowData(L"Downloading app...", 0); - DownloadFile(installPath + L"\\ToolKitV.zip", API_URL DOWNLOAD, L"ToolKitV.zip"); + DownloadFile(installPath + L"\\ToolKitV.zip", downloadUrl, L"ToolKitV.zip"); SetWindowData(L"Unpacking app...", 0); diff --git a/Updater/Updater.cpp b/Updater/Updater.cpp index 1f1911c..c53b14e 100644 --- a/Updater/Updater.cpp +++ b/Updater/Updater.cpp @@ -10,7 +10,7 @@ using namespace std::filesystem; #define MAX_LOADSTRING 100 -#define VERSION "1.1.0" +#define VERSION "1.2.0" HINSTANCE hInst; HWND hWnd; @@ -252,6 +252,10 @@ void InstallOrProceed() { DeleteFile((rootPath + L"\\" PRODUCT_NAME L"_old.exe").c_str()); } + SetWindowData(L"Checking update server...", 0); + + bool updateServerAvaliable = IsUrlValid(API_URL GET_CACHES); + if (DirOrFileExists(appPath) && DirOrFileExists(appPath + exeName) && DirOrFileExists(rootPath + exeName)) { if (ExePath() != rootPath) @@ -275,8 +279,6 @@ void InstallOrProceed() { return; } - bool updateServerAvaliable = IsUrlValid(API_URL GET_CACHES); - if (updateServerAvaliable) { std::string data = GetUrl(API_URL GET_CACHES); @@ -312,7 +314,7 @@ void InstallOrProceed() { } else { - if (PerformInstallation()) + if (PerformInstallation(updateServerAvaliable)) { InstallOrProceed(); } diff --git a/Updater/Updater.h b/Updater/Updater.h index 91e3419..e270dfc 100644 --- a/Updater/Updater.h +++ b/Updater/Updater.h @@ -11,4 +11,5 @@ #define DOWNLOAD_FILE "/toolkitv/files/" #define GET_UPDATER "/toolkitv/updater" #define GET_CACHES "/toolkitv/getCurrentFileCaches" +#define BACKUP_DOWNLOAD_URL "https://github.com/UmbrellaRE/ToolKitV/releases/latest/download/ToolKitV.zip" #define PRODUCT_NAME L"ToolKitV" \ No newline at end of file diff --git a/Updater/installer.h b/Updater/installer.h index 45d940e..23183ed 100644 --- a/Updater/installer.h +++ b/Updater/installer.h @@ -2,4 +2,4 @@ std::wstring GetRootPath(); bool Uninstall(const wchar_t* directory); -bool PerformInstallation(); \ No newline at end of file +bool PerformInstallation(bool updateServerAvaliable); \ No newline at end of file