Display proper error message if Zotero directory or Zotero database is not writable, instead of just if the database isn't readable

This commit is contained in:
Dan Stillman 2010-12-13 22:09:20 +00:00
parent ef36b39454
commit 2f7bf480c0
3 changed files with 28 additions and 2 deletions

View file

@ -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
*/

View file

@ -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') {

View file

@ -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