UI/updater: Use a unique temp path for patch files

Fixes a case where patches for the same destination file but different
source files would clobber each other and cause integrity check
failures.
master
Richard Stanway 2022-09-01 00:37:53 +02:00
parent 09da3ac439
commit 854d75919f
No known key found for this signature in database
GPG Key ID: 4F96FCA24BCE7BA1
1 changed files with 9 additions and 2 deletions

View File

@ -46,6 +46,8 @@ int totalFileSize = 0;
int completedFileSize = 0;
static int completedUpdates = 0;
static wchar_t tempPath[MAX_PATH];
struct LastError {
DWORD code;
inline LastError() { code = GetLastError(); }
@ -879,6 +881,13 @@ static void UpdateWithPatchIfAvailable(const char *name, const char *hash,
update.sourceURL = sourceURL;
update.fileSize = size;
update.patchable = true;
/* Since the patch depends on the previous version, we can
* no longer rely on the temp name being unique to the
* new file's hash */
update.tempPath = tempPath;
update.tempPath += L"\\";
update.tempPath += patchHashStr;
break;
}
}
@ -1065,8 +1074,6 @@ static bool UpdateFile(update_t &file)
return true;
}
static wchar_t tempPath[MAX_PATH] = {};
#define PATCH_MANIFEST_URL \
L"https://obsproject.com/update_studio/getpatchmanifest"
#define HASH_NULL L"0000000000000000000000000000000000000000"