Don't reinstall the entire game if an update was pushed with no updated files

This commit is contained in:
Kawe Mazidjatari 2023-11-18 17:07:48 +01:00
parent dfc9f50176
commit 7a07731457
3 changed files with 26 additions and 9 deletions

View File

@ -332,7 +332,7 @@ void CBaseSurface::OnUpdateClick(Forms::Control* Sender)
CUtlVector<CUtlString> fileList;
CUtlString errorMessage;
if (!SDKLauncher_BeginInstall(false, false, fileList, &errorMessage, pProgress))
if (!SDKLauncher_BeginInstall(false, false, false, fileList, &errorMessage, pProgress))
{
Forms::MessageBox::Show(Format("Failed to install game: %s\n", errorMessage.String()).c_str(),
"Error", Forms::MessageBoxButtons::OK, Forms::MessageBoxIcon::Error);
@ -398,7 +398,7 @@ void CBaseSurface::OnInstallClick(Forms::Control* Sender)
CUtlVector<CUtlString> fileList;
CUtlString errorMessage;
if (!SDKLauncher_BeginInstall(false, false, fileList, &errorMessage, pProgress))
if (!SDKLauncher_BeginInstall(false, false, true, fileList, &errorMessage, pProgress))
{
Forms::MessageBox::Show(Format("Failed to install game: %s\n", errorMessage.String()).c_str(),
"Error", Forms::MessageBoxButtons::OK, Forms::MessageBoxIcon::Error);

View File

@ -509,9 +509,16 @@ bool SDKLauncher_BuildUpdateList(const nlohmann::json& localManifest,
}
//----------------------------------------------------------------------------
// Purpose:
// Purpose: start the automatic installation procedure
// Input : bPreRelease -
// bOptionalDepots -
// bFullInstallWhenListEmpty - if true, installs all depots in the remote manifest when depot list vector is empty
// &zipList -
// *errorMessage -
// *pProgress -
// Output : true on success, false otherwise
//----------------------------------------------------------------------------
bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots,
bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots, const bool bFullInstallWhenListEmpty,
CUtlVector<CUtlString>& zipList, CUtlString* errorMessage, CProgressPanel* pProgress)
{
string responseMessage;
@ -541,6 +548,16 @@ bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots
Assert(depotList.IsEmpty());
}
if (depotList.IsEmpty() && !bFullInstallWhenListEmpty)
{
if (!SDKLauncher_WriteLocalManifest(remoteManifest, errorMessage))
{
return false;
}
return true;
}
FOR_EACH_VEC(depotList, i)
{
const CUtlString& depotName = depotList[i];
@ -565,9 +582,8 @@ bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots
return false;
}
if (!SDKLauncher_WriteLocalManifest(remoteManifest))
if (!SDKLauncher_WriteLocalManifest(remoteManifest, errorMessage))
{
errorMessage->Set("Failed to write local manifest file (insufficient rights?)");
return false;
}
@ -824,11 +840,12 @@ bool SDKLauncher_GetLocalManifest(nlohmann::json& localManifest)
return true;
}
bool SDKLauncher_WriteLocalManifest(const nlohmann::json& localManifest)
bool SDKLauncher_WriteLocalManifest(const nlohmann::json& localManifest, CUtlString* errorMessage)
{
CIOStream writer;
if (!writer.Open(DEPOT_MANIFEST_FILE_PATH, CIOStream::Mode_t::WRITE))
{
errorMessage->Set("Failed to write local manifest file (insufficient rights?)");
return false;
}

View File

@ -11,7 +11,7 @@ bool SDKLauncher_CreateDepotDirectories();
bool SDKLauncher_ClearDepotDirectories();
bool SDKLauncher_ExtractZipFile(nlohmann::json& manifest, const CUtlString& filePath, DepotChangedList_t* changedList, CProgressPanel* pProgress);
bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots,
bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots, const bool bFullInstallWhenListEmpty,
CUtlVector<CUtlString>& zipList, CUtlString* errorMessage, CProgressPanel* pProgress);
bool SDKLauncher_IsManifestValid(const nlohmann::json& depotManifest);
@ -26,7 +26,7 @@ bool SDKLauncher_InstallDepotList(nlohmann::json& manifest, CUtlVector<CUtlStrin
bool SDKLauncher_GetRemoteManifest(const char* url, string& responseMessage, nlohmann::json& remoteManifest, const bool bPreRelease);
bool SDKLauncher_GetLocalManifest(nlohmann::json& localManifest);
bool SDKLauncher_WriteLocalManifest(const nlohmann::json& localManifest);
bool SDKLauncher_WriteLocalManifest(const nlohmann::json& localManifest, CUtlString* errorMessage);
bool SDKLauncher_CheckDiskSpace(const int minRequiredSpace, int* const availableSize = nullptr);
bool SDKLauncher_CheckForUpdate(const bool bPreRelease);