From 052f395ebf54b93ae54f7c98af72962ce0c0358c Mon Sep 17 00:00:00 2001 From: jp9000 Date: Thu, 15 Mar 2018 11:55:13 -0700 Subject: [PATCH] UI/updater: Don't update modules of opposite arch Saves a bit of bandwidth when the update module just updates binaries for the specific architecture being updated. Especially true when libcef needs to be updated. --- UI/win-update/updater/updater.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/UI/win-update/updater/updater.cpp b/UI/win-update/updater/updater.cpp index ed1557db5..5f1d72f01 100644 --- a/UI/win-update/updater/updater.cpp +++ b/UI/win-update/updater/updater.cpp @@ -604,6 +604,11 @@ static inline bool is_64bit_file(const char *file) strstr(file, "64.exe") != nullptr; } +static inline bool has_str(const char *file, const char *str) +{ + return (file && str) ? (strstr(file, str) != nullptr) : false; +} + #define UTF8ToWideBuf(wide, utf8) UTF8ToWide(wide, _countof(wide), utf8) #define WideToUTF8Buf(utf8, wide) WideToUTF8(utf8, _countof(utf8), wide) @@ -657,6 +662,12 @@ static bool AddPackageUpdateFiles(json_t *root, size_t idx, if (!isWin64 && is_64bit_file(fileUTF8)) continue; + /* ignore update files of opposite arch to reduce download */ + + if (( is32bit && has_str(fileUTF8, "/64bit/")) || + (!is32bit && has_str(fileUTF8, "/32bit/"))) + continue; + /* convert strings to wide */ wchar_t sourceURL[1024];