commit 2f7bf480c074764582ce198dbbd24eba3681758c
parent ef36b3945436e5ddb1ab72004ff091dc2aef0a24
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 13 Dec 2010 22:09:20 +0000
Display proper error message if Zotero directory or Zotero database is not writable, instead of just if the database isn't readable
Diffstat:
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js
@@ -77,7 +77,7 @@ Zotero.DBConnection = function(dbName) {
/////////////////////////////////////////////////////////////////
/**
- * Test a connection to the database, throwing any errors that occur
+ * Test a read-only connection to the database, throwing any errors that occur
*
* @return void
*/
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -408,7 +408,33 @@ var Zotero = new function(){
}
try {
+ // Test read access
Zotero.DB.test();
+
+ var dbfile = Zotero.getZoteroDatabase();
+
+ // Test write access on Zotero data directory
+ if (!dbfile.parent.isWritable()) {
+ var msg = 'Cannot write to ' + dbfile.parent.path + '/';
+ }
+ // Test write access on Zotero database
+ else if (!dbfile.isWritable()) {
+ var msg = 'Cannot write to ' + dbfile.path;
+ }
+ else {
+ var msg = false;
+ }
+
+ if (msg) {
+ var e = {
+ name: 'NS_ERROR_FILE_ACCESS_DENIED',
+ message: msg,
+ toString: function () {
+ return this.name + ': ' + this.message;
+ }
+ };
+ throw (e);
+ }
}
catch (e) {
if (e.name == 'NS_ERROR_FILE_ACCESS_DENIED') {
diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties
@@ -80,7 +80,7 @@ startupError.databaseInUse = Your Zotero database is currently in use. Only
startupError.closeStandalone = If Zotero Standalone is open, please close it and restart Firefox.
startupError.closeFirefox = If Firefox with the Zotero extension is open, please close it and restart Zotero Standalone.
startupError.databaseCannotBeOpened = The Zotero database cannot be opened.
-startupError.checkPermissions = Make sure you have read and write permissions to all files in the Zotero data directory.
+startupError.checkPermissions = Make sure you have read and write permissions for all files in the Zotero data directory.
startupError.zoteroVersionIsOlder = This version of Zotero is older than the version last used with your database.
startupError.zoteroVersionIsOlder.upgrade = Please upgrade to the latest version from zotero.org.
startupError.zoteroVersionIsOlder.current = Current version: %S