Automatically create new data directories for additional profiles
E.g., if you have a main profile using ~/Zotero and create a second "Work" profile, a "~/Zotero Work" data directory will be created automatically and set as a custom data directory
This commit is contained in:
parent
0b384abe66
commit
7f81e62bc8
|
@ -182,6 +182,23 @@ Zotero.DataDirectory = {
|
||||||
|
|
||||||
dataDir = this.defaultDir;
|
dataDir = this.defaultDir;
|
||||||
|
|
||||||
|
// If there's already a profile pointing to the default location, use a different
|
||||||
|
// data directory named after the profile, as long as one either doesn't exist yet or
|
||||||
|
// one does and it contains a database
|
||||||
|
try {
|
||||||
|
if ((yield Zotero.Profile.findOtherProfilesUsingDataDirectory(dataDir, false)).length) {
|
||||||
|
let profileName = OS.Path.basename(Zotero.Profile.dir).match(/[^.]+\.(.+)/)[1];
|
||||||
|
let newDataDir = this.defaultDir + ' ' + profileName;
|
||||||
|
if (!(yield OS.File.exists(newDataDir))
|
||||||
|
|| (yield OS.File.exists(OS.Path.join(newDataDir, dbFilename)))) {
|
||||||
|
dataDir = newDataDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
Zotero.logError(e);
|
||||||
|
}
|
||||||
|
|
||||||
// Check for ~/Zotero/zotero.sqlite
|
// Check for ~/Zotero/zotero.sqlite
|
||||||
let dbFile = OS.Path.join(dataDir, dbFilename);
|
let dbFile = OS.Path.join(dataDir, dbFilename);
|
||||||
if (yield OS.File.exists(dbFile)) {
|
if (yield OS.File.exists(dbFile)) {
|
||||||
|
|
|
@ -129,10 +129,12 @@ Zotero.Profile = {
|
||||||
/**
|
/**
|
||||||
* Find other profile directories (for this app or the other app) using the given data directory
|
* Find other profile directories (for this app or the other app) using the given data directory
|
||||||
*
|
*
|
||||||
|
* @param {String} dataDir
|
||||||
|
* @param {Boolean} [includeOtherApps=false] - Check Firefox profiles
|
||||||
* @return {String[]}
|
* @return {String[]}
|
||||||
*/
|
*/
|
||||||
findOtherProfilesUsingDataDirectory: Zotero.Promise.coroutine(function* (dataDir) {
|
findOtherProfilesUsingDataDirectory: Zotero.Promise.coroutine(function* (dataDir, includeOtherApps = true) {
|
||||||
let otherAppProfiles = yield this._findOtherAppProfiles();
|
let otherAppProfiles = includeOtherApps ? (yield this._findOtherAppProfiles()) : [];
|
||||||
let otherProfiles = (yield this._findOtherProfiles()).concat(otherAppProfiles);
|
let otherProfiles = (yield this._findOtherProfiles()).concat(otherAppProfiles);
|
||||||
|
|
||||||
// First get profiles pointing at this directory
|
// First get profiles pointing at this directory
|
||||||
|
|
Loading…
Reference in New Issue
Block a user