From 2f7bf480c074764582ce198dbbd24eba3681758c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 13 Dec 2010 22:09:20 +0000 Subject: [PATCH] Display proper error message if Zotero directory or Zotero database is not writable, instead of just if the database isn't readable --- chrome/content/zotero/xpcom/db.js | 2 +- chrome/content/zotero/xpcom/zotero.js | 26 ++++++++++++++++++++ chrome/locale/en-US/zotero/zotero.properties | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index 14c7a0c96..38be6a6c0 100644 --- 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 index f0be5dcc1..6928ef4b4 100644 --- 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 index f2940c74d..d77d28eed 100644 --- 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