Tweak existing data directory detection

Fixes some issues after f2163b3433
This commit is contained in:
Dan Stillman 2016-11-16 09:49:43 -05:00
parent 71524d9087
commit bc3386ff9d

View file

@ -1080,11 +1080,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
if(defProfile) {
// get Zotero directory
let profileDir = defProfile[0].path;
let zoteroDir = OS.Path.join(profileDir, ZOTERO_CONFIG.ID);
// if Zotero directory exists in default profile for alternative app, use it
if (Zotero.File.pathToFile(zoteroDir).exists()) {
let multipleProfiles = defProfile[1];
Zotero.debug("Found default profile at " + profileDir);
// copy prefs
let prefsFile = OS.Path.join(profileDir, "prefs.js");
@ -1111,16 +1107,21 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
Zotero.Prefs.set(key.substr(ZOTERO_CONFIG.PREF_BRANCH.length), prefs[key]);
}
}
// If data directory setting was transferred, use that
if (Zotero.Prefs.get('useDataDir')) {
return this.getZoteroDirectory();
}
}
// also set data dir if no custom data dir is now defined
if(!Zotero.Prefs.get("useDataDir")) {
// If a custom data directory isn't now defined and there's a data directory in the
// default profile for the alternative app, use that
let zoteroDir = OS.Path.join(profileDir, ZOTERO_CONFIG.ID);
if (!Zotero.Prefs.get("useDataDir") && Zotero.File.pathToFile(profileDir).exists()) {
this.setDataDirectory(zoteroDir);
}
file = Zotero.File.pathToFile(zoteroDir);
}
}
Zotero.File.createDirectoryIfMissing(file);
}