From 06ad369368a0bec62f1cb63e3b03bb250ea72630 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 16 Nov 2016 00:37:24 -0500 Subject: [PATCH] Create database when new data dir location is set in pref Regression from new data directory handling --- chrome/content/zotero/xpcom/zotero.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index e26b2c112..7427644a9 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -271,6 +271,8 @@ Components.utils.import("resource://gre/modules/osfile.jsm"); // Make sure that Zotero Standalone is not running as root if(Zotero.isStandalone && !Zotero.isWin) _checkRoot(); + _addToolbarIcon(); + try { var dataDir = Zotero.getZoteroDirectory(); } @@ -955,10 +957,6 @@ Components.utils.import("resource://gre/modules/osfile.jsm"); throw (e); } this.setDataDirectory(file.path); - if (!file.exists()) { - var e = { name: "NS_ERROR_FILE_NOT_FOUND" }; - throw (e); - } } else { // If there's a migration marker in this directory and no database, migration was @@ -991,6 +989,17 @@ Components.utils.import("resource://gre/modules/osfile.jsm"); } } } + + if (!file.exists()) { + // If useDataDir is set to ~/Zotero and it doesn't exist, create it + if (file.path == this.getDefaultDataDir()) { + Zotero.File.createDirectoryIfMissing(file); + } + else { + let e = { name: "NS_ERROR_FILE_NOT_FOUND" }; + throw e; + } + } } else { let dataDir = this.getDefaultDataDir();