зеркало из https://github.com/mozilla/gecko-dev.git
Fixing bug 57361. Taking care of the cases where people delete parent directories of profiles to not affect registry operations by making sure that profile directory always exists and create a profile in the default user profile location, if needed. r=ccarlen, sr=alecf, a=waterson
This commit is contained in:
Родитель
1ef66b0dbd
Коммит
e1d3c1b57d
|
@ -540,7 +540,7 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName)
|
||||||
#if defined (XP_MAC)
|
#if defined (XP_MAC)
|
||||||
// Need to store persistent strings on mac..
|
// Need to store persistent strings on mac..
|
||||||
PRBool pathChanged = PR_FALSE;
|
PRBool pathChanged = PR_FALSE;
|
||||||
rv = GetProfilePathString(profilePath, (const PRUnichar *) directory.get(), &pathChanged);
|
rv = GetProfilePathString(directory.get(), profile.get(), profilePath, &pathChanged);
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
NS_ENSURE_SUCCESS(rv,rv);
|
||||||
|
|
||||||
if (pathChanged)
|
if (pathChanged)
|
||||||
|
@ -1600,7 +1600,7 @@ nsProfileAccess::DetermineForceMigration(PRBool *forceMigration)
|
||||||
|
|
||||||
// Get the unicode path from the persistent descriptor string
|
// Get the unicode path from the persistent descriptor string
|
||||||
nsresult
|
nsresult
|
||||||
nsProfileAccess::GetProfilePathString(nsString& dirPath, const PRUnichar *dirString, PRBool *pathChanged)
|
nsProfileAccess::GetProfilePathString(const PRUnichar *dirString, const PRUnichar *profileName, nsString& dirPath, PRBool *pathChanged)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
@ -1620,7 +1620,14 @@ nsProfileAccess::GetProfilePathString(nsString& dirPath, const PRUnichar *dirStr
|
||||||
if ( localFile )
|
if ( localFile )
|
||||||
{
|
{
|
||||||
rv = localFile->SetPersistentDescriptor(NS_ConvertUCS2toUTF8(path));
|
rv = localFile->SetPersistentDescriptor(NS_ConvertUCS2toUTF8(path));
|
||||||
|
|
||||||
|
// If persistent opeartion to set the profile dir failed,
|
||||||
|
// We need to build a default path here..
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
{
|
||||||
|
rv = CreateDefaultProfileFolder(profileName, getter_AddRefs(localFile));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
}
|
||||||
|
|
||||||
nsXPIDLString convertedPath;
|
nsXPIDLString convertedPath;
|
||||||
rv = localFile->GetUnicodePath(getter_Copies(convertedPath));
|
rv = localFile->GetUnicodePath(getter_Copies(convertedPath));
|
||||||
|
@ -1667,21 +1674,8 @@ nsProfileAccess::SetProfilePathString(const nsString& dirPath, const nsString& p
|
||||||
// the Documents of the startup volume.
|
// the Documents of the startup volume.
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
{
|
{
|
||||||
// Get default user profiles location
|
// Create a profile folder in default profile location..
|
||||||
nsCOMPtr<nsIFile> newProfileDir;
|
rv = CreateDefaultProfileFolder(profileName.GetUnicode(), getter_AddRefs(localFile));
|
||||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(newProfileDir));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
// append profile name
|
|
||||||
rv = newProfileDir->AppendUnicode(profileName.GetUnicode());
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
// Create unique dir
|
|
||||||
rv = newProfileDir->CreateUnique(NS_ConvertUCS2toUTF8(profileName.GetUnicode()),
|
|
||||||
nsIFile::DIRECTORY_TYPE, 0775);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
localFile = do_QueryInterface(newProfileDir, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1695,3 +1689,32 @@ nsProfileAccess::SetProfilePathString(const nsString& dirPath, const nsString& p
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need to create a default folder with given profile name here...
|
||||||
|
nsresult
|
||||||
|
nsProfileAccess::CreateDefaultProfileFolder(const PRUnichar* profileName, nsILocalFile** newProfileDir)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(profileName, "Invalid Profile name");
|
||||||
|
NS_ENSURE_ARG_POINTER(newProfileDir);
|
||||||
|
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
// Get default user profiles location
|
||||||
|
nsCOMPtr<nsIFile> defaultDir;
|
||||||
|
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(defaultDir));
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
// append profile name
|
||||||
|
rv = defaultDir->AppendUnicode(profileName);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
// Create unique dir
|
||||||
|
rv = defaultDir->CreateUnique(NS_ConvertUCS2toUTF8(profileName),
|
||||||
|
nsIFile::DIRECTORY_TYPE, 0775);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
rv = defaultDir->QueryInterface(NS_GET_IID(nsILocalFile), (void **) newProfileDir);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,8 +123,9 @@ public:
|
||||||
nsresult SetMozRegDataMovedFlag(nsIFile* regName);
|
nsresult SetMozRegDataMovedFlag(nsIFile* regName);
|
||||||
nsresult ResetProfileMembers();
|
nsresult ResetProfileMembers();
|
||||||
nsresult DetermineForceMigration(PRBool *forceMigration);
|
nsresult DetermineForceMigration(PRBool *forceMigration);
|
||||||
nsresult GetProfilePathString(nsString& profilePath, const PRUnichar *dirString, PRBool *pathChanged);
|
nsresult GetProfilePathString(const PRUnichar *dirString, const PRUnichar *profileName, nsString& profilePath, PRBool *pathChanged);
|
||||||
nsresult SetProfilePathString(const nsString& dirPath, const nsString& profileName, nsString& persistentPath);
|
nsresult SetProfilePathString(const nsString& dirPath, const nsString& profileName, nsString& persistentPath);
|
||||||
|
nsresult CreateDefaultProfileFolder(const PRUnichar *profileName, nsILocalFile** profleDir);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __nsProfileAccess_h___
|
#endif // __nsProfileAccess_h___
|
||||||
|
|
Загрузка…
Ссылка в новой задаче