Show better error message if data dir can't be created
This commit is contained in:
parent
e669bf03b0
commit
a47c332895
3 changed files with 77 additions and 1 deletions
|
@ -338,7 +338,75 @@ Zotero.DataDirectory = {
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.debug("Using data directory " + dataDir);
|
Zotero.debug("Using data directory " + dataDir);
|
||||||
|
try {
|
||||||
yield Zotero.File.createDirectoryIfMissingAsync(dataDir);
|
yield Zotero.File.createDirectoryIfMissingAsync(dataDir);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (e instanceof OS.File.Error
|
||||||
|
&& (('unixErrno' in e && e.unixErrno == OS.Constants.libc.EACCES)
|
||||||
|
|| ('winLastError' in e && e.winLastError == OS.Constants.Win.ERROR_ACCESS_DENIED))) {
|
||||||
|
Zotero.restarting = true;
|
||||||
|
let isDefaultDir = dataDir == Zotero.DataDirectory.defaultDir;
|
||||||
|
let ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||||
|
.createInstance(Components.interfaces.nsIPromptService);
|
||||||
|
let buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
|
||||||
|
+ ps.BUTTON_POS_1 * ps.BUTTON_TITLE_IS_STRING;
|
||||||
|
if (!isDefaultDir) {
|
||||||
|
buttonFlags += ps.BUTTON_POS_2 * ps.BUTTON_TITLE_IS_STRING;
|
||||||
|
}
|
||||||
|
let title = Zotero.getString('general.accessDenied');
|
||||||
|
let msg = Zotero.getString('dataDir.dirCannotBeCreated', [Zotero.appName, dataDir])
|
||||||
|
+ "\n\n"
|
||||||
|
+ Zotero.getString('dataDir.checkDirWriteAccess', Zotero.appName);
|
||||||
|
|
||||||
|
let index;
|
||||||
|
if (isDefaultDir) {
|
||||||
|
index = ps.confirmEx(null,
|
||||||
|
title,
|
||||||
|
msg,
|
||||||
|
buttonFlags,
|
||||||
|
Zotero.getString('dataDir.chooseNewDataDirectory'),
|
||||||
|
Zotero.getString('general.quit'),
|
||||||
|
null, null, {}
|
||||||
|
);
|
||||||
|
if (index == 0) {
|
||||||
|
let changed = yield Zotero.DataDirectory.choose(true);
|
||||||
|
if (!changed) {
|
||||||
|
Zotero.Utilities.Internal.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (index == 1) {
|
||||||
|
Zotero.Utilities.Internal.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
index = ps.confirmEx(null,
|
||||||
|
title,
|
||||||
|
msg,
|
||||||
|
buttonFlags,
|
||||||
|
Zotero.getString('dataDir.useDefaultLocation'),
|
||||||
|
Zotero.getString('general.quit'),
|
||||||
|
Zotero.getString('dataDir.chooseNewDataDirectory'),
|
||||||
|
null, {}
|
||||||
|
);
|
||||||
|
if (index == 0) {
|
||||||
|
Zotero.DataDirectory.set(Zotero.DataDirectory.defaultDir);
|
||||||
|
Zotero.Utilities.Internal.quit(true);
|
||||||
|
}
|
||||||
|
else if (index == 1) {
|
||||||
|
Zotero.Utilities.Internal.quit();
|
||||||
|
}
|
||||||
|
else if (index == 2) {
|
||||||
|
let changed = yield Zotero.DataDirectory.choose(true);
|
||||||
|
if (!changed) {
|
||||||
|
Zotero.Utilities.Internal.quit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
this._cache(dataDir);
|
this._cache(dataDir);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
Components.utils.import("resource://gre/modules/osfile.jsm");
|
Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
Components.utils.import("resource://gre/modules/PluralForm.jsm");
|
||||||
|
Components.classes["@mozilla.org/net/osfileconstantsservice;1"]
|
||||||
|
.getService(Components.interfaces.nsIOSFileConstantsService)
|
||||||
|
.init();
|
||||||
|
|
||||||
Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
|
|
||||||
|
@ -288,6 +291,9 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield Zotero.DataDirectory.init();
|
yield Zotero.DataDirectory.init();
|
||||||
|
if (this.restarting) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var dataDir = Zotero.DataDirectory.dir;
|
var dataDir = Zotero.DataDirectory.dir;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
@ -119,6 +119,8 @@ attachmentBasePath.clearBasePath.existingAttachments.singular = One existing at
|
||||||
attachmentBasePath.clearBasePath.existingAttachments.plural = %S existing attachments within the old base directory will be converted to use absolute paths.
|
attachmentBasePath.clearBasePath.existingAttachments.plural = %S existing attachments within the old base directory will be converted to use absolute paths.
|
||||||
attachmentBasePath.clearBasePath.button = Clear Base Directory Setting
|
attachmentBasePath.clearBasePath.button = Clear Base Directory Setting
|
||||||
|
|
||||||
|
dataDir.dirCannotBeCreated = The %S data directory (%S) cannot be created.
|
||||||
|
dataDir.checkDirWriteAccess = Make sure you have write access to this directory and that security software isn’t preventing %S from writing to the disk.
|
||||||
dataDir.databaseCannotBeOpened = The %S database cannot be opened.
|
dataDir.databaseCannotBeOpened = The %S database cannot be opened.
|
||||||
dataDir.checkPermissions = Make sure you have read and write permissions for all files in the %1$S data directory and that security software isn’t preventing %1$S from accessing that directory.
|
dataDir.checkPermissions = Make sure you have read and write permissions for all files in the %1$S data directory and that security software isn’t preventing %1$S from accessing that directory.
|
||||||
dataDir.moveToDefaultLocation = You may be able to fix this problem by moving the data directory to the new default location in your home directory. %S will automatically detect the new location.
|
dataDir.moveToDefaultLocation = You may be able to fix this problem by moving the data directory to the new default location in your home directory. %S will automatically detect the new location.
|
||||||
|
|
Loading…
Reference in a new issue