Fix checking for Firefox profiles high up in filesystem
This was triggering an erroneous warning dialog about a failure to check for Firefox profiles during Linux tests (where the profile is at something like /tmp/tmp.l5phnqSxBH/Zotero), but it could also affect a custom profile directory location.
This commit is contained in:
parent
feb12fafe8
commit
6e2ec2300d
2 changed files with 31 additions and 18 deletions
|
@ -239,19 +239,21 @@ Zotero.DataDirectory = {
|
||||||
// Check Firefox directory
|
// Check Firefox directory
|
||||||
//
|
//
|
||||||
if (!dataDirNamedAfterProfile) {
|
if (!dataDirNamedAfterProfile) {
|
||||||
let profilesParent = OS.Path.dirname(Zotero.Profile.getOtherAppProfilesDir());
|
// Get default profile in Firefox dir
|
||||||
Zotero.debug("Looking for Firefox profile in " + profilesParent);
|
|
||||||
|
|
||||||
// get default profile
|
|
||||||
let defProfile;
|
let defProfile;
|
||||||
try {
|
let profilesDir = Zotero.Profile.getOtherAppProfilesDir();
|
||||||
defProfile = yield Zotero.Profile.getDefaultInProfilesDir(profilesParent);
|
let profilesParent = profilesDir ? OS.Path.dirname(profilesDir) : null;
|
||||||
}
|
if (profilesParent) {
|
||||||
catch (e) {
|
Zotero.debug("Looking for Firefox profile in " + profilesParent);
|
||||||
Zotero.debug("An error occurred locating the Firefox profile; "
|
try {
|
||||||
+ "not attempting to migrate from Zotero for Firefox");
|
defProfile = yield Zotero.Profile.getDefaultInProfilesDir(profilesParent);
|
||||||
Zotero.logError(e);
|
}
|
||||||
Zotero.fxProfileAccessError = true;
|
catch (e) {
|
||||||
|
Zotero.debug("An error occurred locating the Firefox profile; "
|
||||||
|
+ "not attempting to migrate from Zotero for Firefox");
|
||||||
|
Zotero.logError(e);
|
||||||
|
Zotero.fxProfileAccessError = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (defProfile) {
|
if (defProfile) {
|
||||||
let profileDir = defProfile[0];
|
let profileDir = defProfile[0];
|
||||||
|
@ -721,7 +723,11 @@ Zotero.DataDirectory = {
|
||||||
if (currentDir != this.defaultDir) return;
|
if (currentDir != this.defaultDir) return;
|
||||||
if (Zotero.Prefs.get('ignoreLegacyDataDir.auto') || Zotero.Prefs.get('ignoreLegacyDataDir.explicit')) return;
|
if (Zotero.Prefs.get('ignoreLegacyDataDir.auto') || Zotero.Prefs.get('ignoreLegacyDataDir.explicit')) return;
|
||||||
try {
|
try {
|
||||||
let profilesParent = OS.Path.dirname(Zotero.Profile.getOtherAppProfilesDir());
|
let profilesDir = Zotero.Profile.getOtherAppProfilesDir();
|
||||||
|
let profilesParent = profilesDir ? OS.Path.dirname(profilesDir) : null;
|
||||||
|
if (!profilesParent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Zotero.debug("Looking for Firefox profile in " + profilesParent);
|
Zotero.debug("Looking for Firefox profile in " + profilesParent);
|
||||||
|
|
||||||
// get default profile
|
// get default profile
|
||||||
|
|
|
@ -95,10 +95,13 @@ Zotero.Profile = {
|
||||||
* Get the path to the Profiles directory of the other app from this one (Firefox or Zotero),
|
* Get the path to the Profiles directory of the other app from this one (Firefox or Zotero),
|
||||||
* which may or may not exist
|
* which may or may not exist
|
||||||
*
|
*
|
||||||
* @return {String} - Path
|
* @return {String|null} - Path, or null if none due to filesystem location
|
||||||
*/
|
*/
|
||||||
getOtherAppProfilesDir: function () {
|
getOtherAppProfilesDir: function () {
|
||||||
var dir = OS.Path.dirname(OS.Path.dirname(OS.Path.dirname(this.dir)));
|
var dir = OS.Path.dirname(OS.Path.dirname(OS.Path.dirname(this.dir)));
|
||||||
|
if (dir === '' || dir == '.') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (Zotero.isStandalone) {
|
if (Zotero.isStandalone) {
|
||||||
if (Zotero.isWin) {
|
if (Zotero.isWin) {
|
||||||
|
@ -205,7 +208,11 @@ Zotero.Profile = {
|
||||||
*/
|
*/
|
||||||
checkFirefoxProfileAccess: async function () {
|
checkFirefoxProfileAccess: async function () {
|
||||||
try {
|
try {
|
||||||
let profilesParent = OS.Path.dirname(Zotero.Profile.getOtherAppProfilesDir());
|
let profilesDir = Zotero.Profile.getOtherAppProfilesDir();
|
||||||
|
if (!profilesDir) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let profilesParent = OS.Path.dirname(profilesDir);
|
||||||
Zotero.debug("Looking for Firefox profile in " + profilesParent);
|
Zotero.debug("Looking for Firefox profile in " + profilesParent);
|
||||||
let defProfile = await this.getDefaultInProfilesDir(profilesParent);
|
let defProfile = await this.getDefaultInProfilesDir(profilesParent);
|
||||||
if (defProfile) {
|
if (defProfile) {
|
||||||
|
@ -314,8 +321,8 @@ Zotero.Profile = {
|
||||||
*
|
*
|
||||||
* @return {String[]} - Array of paths
|
* @return {String[]} - Array of paths
|
||||||
*/
|
*/
|
||||||
_findOtherAppProfiles: Zotero.Promise.coroutine(function* () {
|
_findOtherAppProfiles: async function () {
|
||||||
var dir = this.getOtherAppProfilesDir();
|
var dir = this.getOtherAppProfilesDir();
|
||||||
return (yield OS.File.exists(dir)) ? this._getProfilesInDir(dir) : [];
|
return dir && await OS.File.exists(dir) ? this._getProfilesInDir(dir) : [];
|
||||||
})
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue