Bug 1532093 - profile-per-install shouldn't use the registry entries for cached hashes. r=bytesized
authorRobert Strong <robert.bugzilla@gmail.com>
Mon, 04 Mar 2019 16:07:53 +0000
changeset 520137 8f8fffb64cd134c4fc468c4d020ae9c5e199f304
parent 520134 a9bb4a23d4072a2735b50b577f9668728af06d30
child 520138 ea800ec9b4ae8877c2bc4b56aa7cf892a2612205
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbytesized
bugs1532093
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532093 - profile-per-install shouldn't use the registry entries for cached hashes. r=bytesized Moves the call to GetCachedHash from GetInstallHash to GetUpdateDirectory Differential Revision: https://phabricator.services.mozilla.com/D21878
toolkit/mozapps/update/common/commonupdatedir.cpp
--- a/toolkit/mozapps/update/common/commonupdatedir.cpp
+++ b/toolkit/mozapps/update/common/commonupdatedir.cpp
@@ -390,36 +390,16 @@ static bool PathConflictsWithLeaf(const 
  * @return NS_OK, if successful.
  */
 nsresult GetInstallHash(const char16_t* installPath, const char* vendor,
                         mozilla::UniquePtr<NS_tchar[]>& result,
                         bool useCompatibilityMode /* = false */) {
   MOZ_ASSERT(installPath != nullptr,
              "Install path must not be null in GetInstallHash");
 
-#ifdef XP_WIN
-  // The Windows installer caches this hash value in the registry
-  SimpleAutoString regPath;
-  regPath.AutoAllocAndAssignSprintf(L"SOFTWARE\\%S\\%S\\TaskBarIDs",
-                                    vendor ? vendor : "Mozilla",
-                                    MOZ_APP_BASENAME);
-  if (regPath.Length() != 0) {
-    bool gotCachedHash =
-        GetCachedHash(installPath, HKEY_LOCAL_MACHINE, regPath, result);
-    if (gotCachedHash) {
-      return NS_OK;
-    }
-    gotCachedHash =
-        GetCachedHash(installPath, HKEY_CURRENT_USER, regPath, result);
-    if (gotCachedHash) {
-      return NS_OK;
-    }
-  }
-#endif
-
   // Unable to get the cached hash, so compute it.
   size_t pathSize =
       std::char_traits<char16_t>::length(installPath) * sizeof(*installPath);
   uint64_t hash =
       CityHash64(reinterpret_cast<const char*>(installPath), pathSize);
 
   size_t hashStrSize = sizeof(hash) * 2 + 1;  // 2 hex digits per byte + null
   result = mozilla::MakeUnique<NS_tchar[]>(hashStrSize);
@@ -592,19 +572,37 @@ static HRESULT GetUpdateDirectory(const 
     return E_FAIL;
   }
 
   // Generate the update directory path. This is the value to be returned by
   // this function.
   SimpleAutoString updatePath;
   if (installPath) {
     mozilla::UniquePtr<NS_tchar[]> hash;
-    bool useCompatibilityMode = (whichDir == WhichUpdateDir::UserAppData);
-    nsresult rv = GetInstallHash(reinterpret_cast<const char16_t*>(installPath),
-                                 vendor, hash, useCompatibilityMode);
+
+    // The Windows installer caches this hash value in the registry
+    bool gotHash = false;
+    SimpleAutoString regPath;
+    regPath.AutoAllocAndAssignSprintf(L"SOFTWARE\\%S\\%S\\TaskBarIDs",
+                                      vendor ? vendor : "Mozilla",
+                                      MOZ_APP_BASENAME);
+    if (regPath.Length() != 0) {
+      gotHash = GetCachedHash(reinterpret_cast<const char16_t*>(installPath),
+                              HKEY_LOCAL_MACHINE, regPath, hash);
+      if (!gotHash) {
+        gotHash = GetCachedHash(reinterpret_cast<const char16_t*>(installPath),
+                                HKEY_CURRENT_USER, regPath, hash);
+      }
+    }
+    nsresult rv = NS_OK;
+    if (!gotHash) {
+      bool useCompatibilityMode = (whichDir == WhichUpdateDir::UserAppData);
+      rv = GetInstallHash(reinterpret_cast<const char16_t*>(installPath),
+                          vendor, hash, useCompatibilityMode);
+    }
     if (NS_SUCCEEDED(rv)) {
       const wchar_t midPathDirName[] = NS_T(UPDATE_PATH_MID_DIR_NAME);
       size_t updatePathLen = basePath.Length() + 1 /* path separator */ +
                              wcslen(midPathDirName) + 1 /* path separator */ +
                              wcslen(hash.get());
       updatePath.AllocAndAssignSprintf(updatePathLen, L"%s\\%s\\%s",
                                        basePath.String(), midPathDirName,
                                        hash.get());