Bug 1233434 - Fixing download failure on a multi-user GNU/Linux machine. r=bagder

This commit is contained in:
Aidin Gharibnavaz 2015-12-19 22:11:00 +03:30
parent fb8dd89d01
commit 7781b79a4e

View File

@ -416,12 +416,12 @@ static nsresult GetDownloadDirectory(nsIFile **_directory,
const char* userName = PR_GetEnv("USERNAME");
if (!userName || !*userName) {
userName = PR_GetEnv("USER");
if (!userName || !*userName) {
userName = PR_GetEnv("LOGNAME");
}
else {
userName = "mozillaUser";
}
}
if (!userName || !*userName) {
userName = PR_GetEnv("LOGNAME");
}
if (!userName || !*userName) {
userName = "mozillaUser";
}
nsAutoString userDir;
@ -447,7 +447,12 @@ static nsresult GetDownloadDirectory(nsIFile **_directory,
rv = finalPath->GetPermissions(&permissions);
NS_ENSURE_SUCCESS(rv, rv);
if (permissions == PR_IRWXU) {
// Ensuring the path is writable by the current user.
bool isWritable;
rv = finalPath->IsWritable(&isWritable);
NS_ENSURE_SUCCESS(rv, rv);
if (permissions == PR_IRWXU && isWritable) {
dir = finalPath;
break;
}