Skip to content

Commit

Permalink
UI/updater: Fix files with similar hashes clashing
Browse files Browse the repository at this point in the history
Do to multithreading the update process, files of the same hash can
sometimes collide due to race. Ensure the filenames are all unique by
appending an incremented value for each file.
  • Loading branch information
jp9000 committed Sep 1, 2022
1 parent e87a97e commit 7396c21
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions UI/win-update/updater/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,12 +885,16 @@ static void UpdateWithPatchIfAvailable(const char *name, const char *hash,
update.fileSize = size;
update.patchable = true;

/* ensure the filename is unique */
static long increment = 0;

/* 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;
update.tempPath += std::to_wstring(increment++);
break;
}
}
Expand Down

0 comments on commit 7396c21

Please sign in to comment.