diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index 629b520779fd..920f225c248c 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -289,6 +289,23 @@ RegisterGenericFactory(nsIComponentRegistrar* registrar, static PRBool CheckUpdateFile() { nsresult rv; + nsCOMPtr compregFile; + rv = nsDirectoryService::gService->Get(NS_XPCOM_COMPONENT_REGISTRY_FILE, + NS_GET_IID(nsIFile), + getter_AddRefs(compregFile)); + + if (NS_FAILED(rv)) { + NS_WARNING("Getting NS_XPCOM_COMPONENT_REGISTRY_FILE failed"); + return PR_FALSE; + } + + PRBool exists; + if (NS_FAILED(compregFile->Exists(&exists)) || !exists) + return PR_TRUE; + + PRInt64 compregModTime; + compregFile->GetLastModifiedTime(&compregModTime); + nsCOMPtr file; rv = nsDirectoryService::gService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), @@ -301,28 +318,39 @@ static PRBool CheckUpdateFile() file->AppendNative(nsDependentCString(".autoreg")); - PRBool exists; file->Exists(&exists); if (!exists) - return PR_FALSE; + goto next; - nsCOMPtr compregFile; - rv = nsDirectoryService::gService->Get(NS_XPCOM_COMPONENT_REGISTRY_FILE, + PRInt64 autoregModTime; + file->GetLastModifiedTime(&autoregModTime); + + if (LL_CMP(autoregModTime, >, compregModTime)) + return PR_TRUE; + +next: + nsCOMPtr greFile; + rv = nsDirectoryService::gService->Get(NS_GRE_DIR, NS_GET_IID(nsIFile), - getter_AddRefs(compregFile)); + getter_AddRefs(greFile)); - if (NS_FAILED(rv)) { - NS_WARNING("Getting NS_XPCOM_COMPONENT_REGISTRY_FILE failed"); + NS_WARNING("Getting NS_GRE_DIR failed"); return PR_FALSE; } - if (NS_FAILED(compregFile->Exists(&exists)) || !exists) - return PR_TRUE; + greFile->AppendNative(nsDependentCString(".autoreg")); - PRInt64 compregModTime, autoregModTime; - compregFile->GetLastModifiedTime(&compregModTime); - file->GetLastModifiedTime(&autoregModTime); + PRBool equals; + rv = greFile->Equals(file, &equals); + if (NS_SUCCEEDED(rv) && equals) + return PR_FALSE; + + greFile->Exists(&exists); + if (!exists) + return PR_FALSE; + + greFile->GetLastModifiedTime(&autoregModTime); return LL_CMP(autoregModTime, >, compregModTime); }