diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index 4b347a6a8e..94f171f511 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -569,13 +569,28 @@ Zotero_Preferences.Attachment_Base_Directory = { return false; } - return this.changePath(newPath); + try { + return await this.changePath(newPath); + } + catch (e) { + Zotero.logError(e); + Zotero.alert(null, Zotero.getString('general.error'), e.message); + } }, changePath: Zotero.Promise.coroutine(function* (basePath) { Zotero.debug(`New base directory is ${basePath}`); + if (Zotero.File.directoryContains(Zotero.DataDirectory.dir, basePath)) { + throw new Error( + Zotero.getString( + 'zotero.preferences.advanced.baseDirectory.withinDataDir', + Zotero.appName + ) + ); + } + // Find all current attachments with relative attachment paths var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=? AND path LIKE ?"; var params = [ @@ -693,7 +708,7 @@ Zotero_Preferences.Attachment_Base_Directory = { return false; } - // Set new data directory + // Set new base directory Zotero.debug("Setting base directory to " + basePath); Zotero.Prefs.set('baseAttachmentPath', basePath); Zotero.Prefs.set('saveRelativeAttachmentPath', true); diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 822df434ab..454ab06dec 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -685,6 +685,7 @@ zotero.preferences.wordProcessors.incompatibleVersions2 = %1$S %2$S requires %3 zotero.preferences.styles.addStyle = Add Style +zotero.preferences.advanced.baseDirectory.withinDataDir = You cannot select a Linked Attachment Base Directory within the %S data directory. zotero.preferences.advanced.resetTranslatorsAndStyles = Reset Translators and Styles zotero.preferences.advanced.resetTranslatorsAndStyles.changesLost = Any new or modified translators or styles will be lost. zotero.preferences.advanced.resetTranslators = Reset Translators