Update deprecated uses of Zotero.getZoteroDirectory()/getZoteroDatabase()
The Zotero.DataDirectory equivalents return string paths instead of nsIFile instances, so some of these calls now just use Zotero.File.pathToFile(), which can be removed when the surrounding code is updated to OS.File,
This commit is contained in:
parent
4c0abb6816
commit
5a6f1eef63
16 changed files with 88 additions and 101 deletions
|
@ -229,8 +229,7 @@ var ZoteroOverlay = new function()
|
||||||
ZoteroPane.makeVisible();
|
ZoteroPane.makeVisible();
|
||||||
|
|
||||||
// Warn about unsafe data directory on first display
|
// Warn about unsafe data directory on first display
|
||||||
let dataDir = Zotero.getZoteroDirectory();
|
Zotero.DataDirectory.checkForUnsafeLocation(Zotero.DataDirectory.dir); // async
|
||||||
Zotero.DataDirectory.checkForUnsafeLocation(dataDir.path); // async
|
|
||||||
|
|
||||||
// Make sure tags splitter isn't missing for people upgrading from <2.0b7
|
// Make sure tags splitter isn't missing for people upgrading from <2.0b7
|
||||||
document.getElementById('zotero-tags-splitter').collapsed = false;
|
document.getElementById('zotero-tags-splitter').collapsed = false;
|
||||||
|
|
|
@ -181,7 +181,7 @@ Zotero_Preferences.Sync = {
|
||||||
);
|
);
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
if (check.value) {
|
if (check.value) {
|
||||||
var resetDataDirFile = OS.Path.join(Zotero.getZoteroDirectory().path, 'reset-data-directory');
|
var resetDataDirFile = OS.Path.join(Zotero.DataDirectory.dir, 'reset-data-directory');
|
||||||
yield Zotero.File.putContentsAsync(resetDataDirFile, '');
|
yield Zotero.File.putContentsAsync(resetDataDirFile, '');
|
||||||
|
|
||||||
yield Zotero.Sync.Runner.deleteAPIKey();
|
yield Zotero.Sync.Runner.deleteAPIKey();
|
||||||
|
@ -645,9 +645,10 @@ Zotero_Preferences.Sync = {
|
||||||
|
|
||||||
Zotero.DB.skipBackup = true;
|
Zotero.DB.skipBackup = true;
|
||||||
|
|
||||||
var file = Zotero.getZoteroDirectory();
|
yield Zotero.File.putContentsAsync(
|
||||||
file.append('restore-from-server');
|
OS.Path.join(Zotero.DataDirectory.dir, 'restore-from-server'),
|
||||||
Zotero.File.putContents(file, '');
|
''
|
||||||
|
);
|
||||||
|
|
||||||
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
|
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING);
|
||||||
var index = ps.confirmEx(
|
var index = ps.confirmEx(
|
||||||
|
|
|
@ -141,7 +141,7 @@ var Zotero_RecognizePDF = new function() {
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
function _extractText(file, pages) {
|
function _extractText(file, pages) {
|
||||||
var cacheFile = Zotero.getZoteroDirectory();
|
var cacheFile = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
cacheFile.append("recognizePDFcache.txt");
|
cacheFile.append("recognizePDFcache.txt");
|
||||||
if(cacheFile.exists()) {
|
if(cacheFile.exists()) {
|
||||||
cacheFile.remove(false);
|
cacheFile.remove(false);
|
||||||
|
|
|
@ -1190,40 +1190,20 @@ Zotero.Attachments = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create orphaned-files directory if it doesn't exist
|
// Create orphaned-files directory if it doesn't exist
|
||||||
var orphaned = Zotero.getZoteroDirectory();
|
var orphaned = OS.Path.join(Zotero.DataDirectory.dir, 'orphaned-files');
|
||||||
orphaned.append('orphaned-files');
|
yield Zotero.File.createDirectoryIfMissingAsync(orphaned);
|
||||||
if (!orphaned.exists()) {
|
|
||||||
orphaned.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find unique filename for orphaned file
|
// Find unique filename for orphaned file
|
||||||
var orphanTarget = orphaned.clone();
|
var orphanTarget = OS.Path.join(orphaned, dir.leafName);
|
||||||
orphanTarget.append(dir.leafName);
|
|
||||||
var newName = null;
|
var newName = null;
|
||||||
if (orphanTarget.exists()) {
|
if (yield OS.File.exists(orphanTarget)) {
|
||||||
try {
|
let newFile = yield OS.File.openUnique(orphanTarget, { humanReadable: true })
|
||||||
orphanTarget.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
|
newName = OS.Path.basename(newFile.path);
|
||||||
newName = orphanTarget.leafName;
|
newFile.file.close();
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
// DEBUG: Work around createUnique() brokenness on Windows
|
|
||||||
// as of Fx3.0.3 (https://bugzilla.mozilla.org/show_bug.cgi?id=452217)
|
|
||||||
//
|
|
||||||
// We just delete the conflicting file
|
|
||||||
if (Zotero.isWin && e.name == 'NS_ERROR_FILE_ACCESS_DENIED') {
|
|
||||||
orphanTarget.remove(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw (e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (newName) {
|
|
||||||
orphanTarget.remove(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move target to orphaned files directory
|
// Move target to orphaned files directory
|
||||||
dir.moveTo(orphaned, newName);
|
dir.moveTo(Zotero.File.pathToFile(orphaned), newName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -333,7 +333,7 @@ Zotero.Cite.getAbbreviation = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAbbreviations() {
|
function loadAbbreviations() {
|
||||||
var file = Zotero.getZoteroDirectory();
|
var file = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
file.append("abbreviations.json");
|
file.append("abbreviations.json");
|
||||||
|
|
||||||
var json, origin;
|
var json, origin;
|
||||||
|
|
|
@ -874,7 +874,7 @@ Zotero.DBConnection.prototype.integrityCheck = Zotero.Promise.coroutine(function
|
||||||
Zotero.DBConnection.prototype.checkException = function (e) {
|
Zotero.DBConnection.prototype.checkException = function (e) {
|
||||||
if (e.name && e.name == 'NS_ERROR_FILE_CORRUPTED') {
|
if (e.name && e.name == 'NS_ERROR_FILE_CORRUPTED') {
|
||||||
// Write corrupt marker to data directory
|
// Write corrupt marker to data directory
|
||||||
var file = Zotero.getZoteroDatabase(this._dbName, 'is.corrupt');
|
var file = Zotero.File.pathToFile(Zotero.DataDirectory.getDatabase(this._dbName, 'is.corrupt'));
|
||||||
Zotero.File.putContents(file, '');
|
Zotero.File.putContents(file, '');
|
||||||
|
|
||||||
this._dbIsCorrupt = true;
|
this._dbIsCorrupt = true;
|
||||||
|
@ -956,7 +956,9 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var corruptMarker = Zotero.getZoteroDatabase(this._dbName, 'is.corrupt');
|
var corruptMarker = Zotero.File.pathToFile(
|
||||||
|
Zotero.DataDirectory.getDatabase(this._dbName, 'is.corrupt')
|
||||||
|
);
|
||||||
|
|
||||||
if (this.skipBackup || Zotero.skipLoading) {
|
if (this.skipBackup || Zotero.skipLoading) {
|
||||||
this._debug("Skipping backup of database '" + this._dbName + "'", 1);
|
this._debug("Skipping backup of database '" + this._dbName + "'", 1);
|
||||||
|
@ -967,11 +969,11 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var file = Zotero.getZoteroDatabase(this._dbName);
|
var file = Zotero.File.pathToFile(Zotero.DataDirectory.getDatabase(this._dbName));
|
||||||
|
|
||||||
// For standard backup, make sure last backup is old enough to replace
|
// For standard backup, make sure last backup is old enough to replace
|
||||||
if (!suffix && !force) {
|
if (!suffix && !force) {
|
||||||
var backupFile = Zotero.getZoteroDatabase(this._dbName, 'bak');
|
var backupFile = Zotero.File.pathToFile(Zotero.DataDirectory.getDatabase(this._dbName, 'bak'));
|
||||||
if (yield OS.File.exists(backupFile.path)) {
|
if (yield OS.File.exists(backupFile.path)) {
|
||||||
var currentDBTime = (yield OS.File.stat(file.path)).lastModificationDate;
|
var currentDBTime = (yield OS.File.stat(file.path)).lastModificationDate;
|
||||||
var lastBackupTime = (yield OS.File.stat(backupFile.path)).lastModificationDate;
|
var lastBackupTime = (yield OS.File.stat(backupFile.path)).lastModificationDate;
|
||||||
|
@ -995,14 +997,14 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
|
||||||
|
|
||||||
// Copy via a temporary file so we don't run into disk space issues
|
// Copy via a temporary file so we don't run into disk space issues
|
||||||
// after deleting the old backup file
|
// after deleting the old backup file
|
||||||
var tmpFile = Zotero.getZoteroDatabase(this._dbName, 'tmp');
|
var tmpFile = Zotero.DataDirectory.getDatabase(this._dbName, 'tmp');
|
||||||
if (yield OS.File.exists(tmpFile.path)) {
|
if (yield OS.File.exists(tmpFile)) {
|
||||||
try {
|
try {
|
||||||
yield OS.File.remove(tmpFile.path);
|
yield OS.File.remove(tmpFile);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (e.name == 'NS_ERROR_FILE_ACCESS_DENIED') {
|
if (e.name == 'NS_ERROR_FILE_ACCESS_DENIED') {
|
||||||
alert("Cannot delete " + tmpFile.leafName);
|
alert("Cannot delete " + OS.Path.basename(tmpFile));
|
||||||
}
|
}
|
||||||
throw (e);
|
throw (e);
|
||||||
}
|
}
|
||||||
|
@ -1053,9 +1055,9 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
|
||||||
// Special backup
|
// Special backup
|
||||||
if (!suffix && numBackups > 1) {
|
if (!suffix && numBackups > 1) {
|
||||||
// Remove oldest backup file
|
// Remove oldest backup file
|
||||||
var targetFile = Zotero.getZoteroDatabase(this._dbName, (numBackups - 1) + '.bak')
|
var targetFile = Zotero.DataDirectory.getDatabase(this._dbName, (numBackups - 1) + '.bak');
|
||||||
if (yield OS.File.exists(targetFile.path)) {
|
if (yield OS.File.exists(targetFile)) {
|
||||||
yield OS.File.remove(targetFile.path);
|
yield OS.File.remove(targetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift old versions up
|
// Shift old versions up
|
||||||
|
@ -1063,33 +1065,34 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
|
||||||
var targetNum = i;
|
var targetNum = i;
|
||||||
var sourceNum = targetNum - 1;
|
var sourceNum = targetNum - 1;
|
||||||
|
|
||||||
var targetFile = Zotero.getZoteroDatabase(
|
var targetFile = Zotero.DataDirectory.getDatabase(
|
||||||
this._dbName, targetNum + '.bak'
|
this._dbName, targetNum + '.bak'
|
||||||
);
|
);
|
||||||
var sourceFile = Zotero.getZoteroDatabase(
|
var sourceFile = Zotero.DataDirectory.getDatabase(
|
||||||
this._dbName, sourceNum ? sourceNum + '.bak' : 'bak'
|
this._dbName, sourceNum ? sourceNum + '.bak' : 'bak'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!(yield OS.File.exists(sourceFile.path))) {
|
if (!(yield OS.File.exists(sourceFile))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.debug("Moving " + sourceFile.leafName + " to " + targetFile.leafName);
|
Zotero.debug("Moving " + OS.Path.basename(sourceFile)
|
||||||
yield OS.File.move(sourceFile.path, targetFile.path);
|
+ " to " + OS.Path.basename(targetFile));
|
||||||
|
yield OS.File.move(sourceFile, targetFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var backupFile = Zotero.getZoteroDatabase(
|
var backupFile = Zotero.DataDirectory.getDatabase(
|
||||||
this._dbName, (suffix ? suffix + '.' : '') + 'bak'
|
this._dbName, (suffix ? suffix + '.' : '') + 'bak'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove old backup file
|
// Remove old backup file
|
||||||
if (yield OS.File.exists(backupFile.path)) {
|
if (yield OS.File.exists(backupFile)) {
|
||||||
OS.File.remove(backupFile.path);
|
OS.File.remove(backupFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield OS.File.move(tmpFile.path, backupFile.path);
|
yield OS.File.move(tmpFile.path, backupFile);
|
||||||
Zotero.debug("Backed up to " + backupFile.leafName);
|
Zotero.debug("Backed up to " + OS.Path.basename(backupFile));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1138,13 +1141,13 @@ Zotero.DBConnection.prototype._getConnectionAsync = Zotero.Promise.coroutine(fun
|
||||||
var store = Components.classes["@mozilla.org/storage/service;1"].
|
var store = Components.classes["@mozilla.org/storage/service;1"].
|
||||||
getService(Components.interfaces.mozIStorageService);
|
getService(Components.interfaces.mozIStorageService);
|
||||||
|
|
||||||
var file = Zotero.getZoteroDatabase(this._dbName);
|
var file = Zotero.File.pathToFile(Zotero.DataDirectory.getDatabase(this._dbName));
|
||||||
var backupFile = Zotero.getZoteroDatabase(this._dbName, 'bak');
|
var backupFile = Zotero.File.pathToFile(Zotero.DataDirectory.getDatabase(this._dbName, 'bak'));
|
||||||
|
|
||||||
var fileName = this._dbName + '.sqlite';
|
var fileName = this._dbName + '.sqlite';
|
||||||
|
|
||||||
catchBlock: try {
|
catchBlock: try {
|
||||||
var corruptMarker = Zotero.getZoteroDatabase(this._dbName, 'is.corrupt');
|
var corruptMarker = Zotero.File.pathToFile(Zotero.DataDirectory.getDatabase(this._dbName, 'is.corrupt'));
|
||||||
if (corruptMarker.exists()) {
|
if (corruptMarker.exists()) {
|
||||||
throw {
|
throw {
|
||||||
name: 'NS_ERROR_FILE_CORRUPTED'
|
name: 'NS_ERROR_FILE_CORRUPTED'
|
||||||
|
@ -1164,11 +1167,13 @@ Zotero.DBConnection.prototype._getConnectionAsync = Zotero.Promise.coroutine(fun
|
||||||
|
|
||||||
// Save damaged filed
|
// Save damaged filed
|
||||||
this._debug('Saving damaged DB file with .damaged extension', 1);
|
this._debug('Saving damaged DB file with .damaged extension', 1);
|
||||||
var damagedFile = Zotero.getZoteroDatabase(this._dbName, 'damaged');
|
var damagedFile = Zotero.File.pathToFile(
|
||||||
|
Zotero.DataDirectory.getDatabase(this._dbName, 'damaged')
|
||||||
|
);
|
||||||
Zotero.moveToUnique(file, damagedFile);
|
Zotero.moveToUnique(file, damagedFile);
|
||||||
|
|
||||||
// Create new main database
|
// Create new main database
|
||||||
var file = Zotero.getZoteroDatabase(this._dbName);
|
var file = Zotero.File.pathToFile(Zotero.DataDirectory.getDatabase(this._dbName));
|
||||||
this._connection = store.openDatabase(file);
|
this._connection = store.openDatabase(file);
|
||||||
|
|
||||||
if (corruptMarker.exists()) {
|
if (corruptMarker.exists()) {
|
||||||
|
@ -1181,7 +1186,9 @@ Zotero.DBConnection.prototype._getConnectionAsync = Zotero.Promise.coroutine(fun
|
||||||
|
|
||||||
// Save damaged file
|
// Save damaged file
|
||||||
this._debug('Saving damaged DB file with .damaged extension', 1);
|
this._debug('Saving damaged DB file with .damaged extension', 1);
|
||||||
var damagedFile = Zotero.getZoteroDatabase(this._dbName, 'damaged');
|
var damagedFile = Zotero.File.pathToFile(
|
||||||
|
Zotero.DataDirectory.getDatabase(this._dbName, 'damaged')
|
||||||
|
);
|
||||||
Zotero.moveToUnique(file, damagedFile);
|
Zotero.moveToUnique(file, damagedFile);
|
||||||
|
|
||||||
// Test the backup file
|
// Test the backup file
|
||||||
|
@ -1194,7 +1201,7 @@ Zotero.DBConnection.prototype._getConnectionAsync = Zotero.Promise.coroutine(fun
|
||||||
// Can't open backup either
|
// Can't open backup either
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// Create new main database
|
// Create new main database
|
||||||
var file = Zotero.getZoteroDatabase(this._dbName);
|
var file = Zotero.File.pathToFile(Zotero.DataDirectory.getDatabase(this._dbName));
|
||||||
this._connection = yield Zotero.Promise.resolve(this.Sqlite.openConnection({
|
this._connection = yield Zotero.Promise.resolve(this.Sqlite.openConnection({
|
||||||
path: file.path
|
path: file.path
|
||||||
}));
|
}));
|
||||||
|
@ -1221,10 +1228,9 @@ Zotero.DBConnection.prototype._getConnectionAsync = Zotero.Promise.coroutine(fun
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open restored database
|
// Open restored database
|
||||||
var file = Zotero.getZoteroDirectory();
|
var file = OS.Path.join(Zotero.DataDirectory.dir, fileName);
|
||||||
file.append(fileName);
|
|
||||||
this._connection = yield Zotero.Promise.resolve(this.Sqlite.openConnection({
|
this._connection = yield Zotero.Promise.resolve(this.Sqlite.openConnection({
|
||||||
path: file.path
|
path: file
|
||||||
}));
|
}));
|
||||||
this._debug('Database restored', 1);
|
this._debug('Database restored', 1);
|
||||||
var msg = Zotero.getString('db.dbRestored', [
|
var msg = Zotero.getString('db.dbRestored', [
|
||||||
|
|
|
@ -261,7 +261,7 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var destDir = Zotero.getZoteroDirectory()
|
var destDir = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
// Move redirect script and executable into data dir
|
// Move redirect script and executable into data dir
|
||||||
if (tmpScriptFile) {
|
if (tmpScriptFile) {
|
||||||
yield OS.File.move(
|
yield OS.File.move(
|
||||||
|
@ -292,7 +292,7 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
*/
|
*/
|
||||||
this.registerPDFTool = Zotero.Promise.coroutine(function* (tool) {
|
this.registerPDFTool = Zotero.Promise.coroutine(function* (tool) {
|
||||||
var errMsg = false;
|
var errMsg = false;
|
||||||
var exec = Zotero.getZoteroDirectory();
|
var exec = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
|
|
||||||
switch (tool) {
|
switch (tool) {
|
||||||
case 'converter':
|
case 'converter':
|
||||||
|
@ -342,7 +342,7 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
case 'converter':
|
case 'converter':
|
||||||
// TEMP: disabled
|
// TEMP: disabled
|
||||||
if (false && Zotero.isWin) {
|
if (false && Zotero.isWin) {
|
||||||
var script = Zotero.getZoteroDirectory();
|
var script = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
script.append('pdftotext.' + _getScriptExtension())
|
script.append('pdftotext.' + _getScriptExtension())
|
||||||
if (script.exists()) {
|
if (script.exists()) {
|
||||||
Zotero.debug(script.leafName + " registered");
|
Zotero.debug(script.leafName + " registered");
|
||||||
|
@ -355,7 +355,7 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
// Modified 3.02 version doesn't use redirection script
|
// Modified 3.02 version doesn't use redirection script
|
||||||
if (version.startsWith('3.02')) break;
|
if (version.startsWith('3.02')) break;
|
||||||
|
|
||||||
var script = Zotero.getZoteroDirectory();
|
var script = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
// TEMP: disabled on Win
|
// TEMP: disabled on Win
|
||||||
if (!Zotero.isWin) {
|
if (!Zotero.isWin) {
|
||||||
script.append('pdfinfo.' + _getScriptExtension())
|
script.append('pdfinfo.' + _getScriptExtension())
|
||||||
|
@ -396,7 +396,6 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
this.uninstallPDFTools = Zotero.Promise.coroutine(function* () {
|
this.uninstallPDFTools = Zotero.Promise.coroutine(function* () {
|
||||||
Zotero.debug("Uninstalling PDF tools");
|
Zotero.debug("Uninstalling PDF tools");
|
||||||
|
|
||||||
var dataDir = Zotero.getZoteroDirectory().path;
|
|
||||||
if (_pdfConverter) {
|
if (_pdfConverter) {
|
||||||
yield Zotero.File.removeIfExists(_pdfConverter.path);
|
yield Zotero.File.removeIfExists(_pdfConverter.path);
|
||||||
yield Zotero.File.removeIfExists(_pdfConverter.path + ".version");
|
yield Zotero.File.removeIfExists(_pdfConverter.path + ".version");
|
||||||
|
|
|
@ -66,7 +66,7 @@ Zotero.IPC = new function() {
|
||||||
// Standalone sends this to the Firefox extension to tell the Firefox extension to
|
// Standalone sends this to the Firefox extension to tell the Firefox extension to
|
||||||
// release its lock on the Zotero database
|
// release its lock on the Zotero database
|
||||||
if(!Zotero.isConnector && (msg.length === 11 ||
|
if(!Zotero.isConnector && (msg.length === 11 ||
|
||||||
msg.substr(12) === Zotero.getZoteroDatabase().persistentDescriptor)) {
|
msg.substr(12) === Zotero.DataDirectory.getDatabase())) {
|
||||||
switchConnectorMode(true);
|
switchConnectorMode(true);
|
||||||
}
|
}
|
||||||
} else if(msg === "lockReleased") {
|
} else if(msg === "lockReleased") {
|
||||||
|
@ -284,7 +284,7 @@ Zotero.IPC = new function() {
|
||||||
* Get directory containing Zotero pipes
|
* Get directory containing Zotero pipes
|
||||||
*/
|
*/
|
||||||
function _getPipeDirectory() {
|
function _getPipeDirectory() {
|
||||||
var dir = Zotero.getZoteroDirectory();
|
var dir = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
dir.append("pipes");
|
dir.append("pipes");
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ Zotero.LocateManager = new function() {
|
||||||
* Gets the dir containing the JSON file and engine icons
|
* Gets the dir containing the JSON file and engine icons
|
||||||
*/
|
*/
|
||||||
function _getLocateDirectory() {
|
function _getLocateDirectory() {
|
||||||
var locateDir = Zotero.getZoteroDirectory();
|
var locateDir = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
locateDir.append(LOCATE_DIR_NAME);
|
locateDir.append(LOCATE_DIR_NAME);
|
||||||
return locateDir;
|
return locateDir;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ Zotero.Schema = new function(){
|
||||||
if (updated) {
|
if (updated) {
|
||||||
// Upgrade seems to have been a success -- delete any previous backups
|
// Upgrade seems to have been a success -- delete any previous backups
|
||||||
var maxPrevious = userdata - 1;
|
var maxPrevious = userdata - 1;
|
||||||
var file = Zotero.getZoteroDirectory();
|
var file = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
var toDelete = [];
|
var toDelete = [];
|
||||||
try {
|
try {
|
||||||
var files = file.directoryEntries;
|
var files = file.directoryEntries;
|
||||||
|
|
|
@ -131,7 +131,7 @@ Zotero.Sync.Data.Local = {
|
||||||
|
|
||||||
var accept = false;
|
var accept = false;
|
||||||
if (io.accept) {
|
if (io.accept) {
|
||||||
var resetDataDirFile = OS.Path.join(Zotero.getZoteroDirectory().path, 'reset-data-directory');
|
var resetDataDirFile = OS.Path.join(Zotero.DataDirectory.dir, 'reset-data-directory');
|
||||||
yield Zotero.File.putContentsAsync(resetDataDirFile, '');
|
yield Zotero.File.putContentsAsync(resetDataDirFile, '');
|
||||||
|
|
||||||
Zotero.Utilities.Internal.quitZotero(true);
|
Zotero.Utilities.Internal.quitZotero(true);
|
||||||
|
|
|
@ -470,7 +470,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
// TODO: Back up database
|
// TODO: Back up database
|
||||||
|
|
||||||
|
|
||||||
var dbfile = Zotero.getZoteroDatabase().path;
|
var dbfile = Zotero.DataDirectory.getDatabase();
|
||||||
yield OS.File.remove(dbfile, {ignoreAbsent: true});
|
yield OS.File.remove(dbfile, {ignoreAbsent: true});
|
||||||
|
|
||||||
if (Zotero.restoreFromServer) {
|
if (Zotero.restoreFromServer) {
|
||||||
|
@ -755,20 +755,20 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
// Test read access
|
// Test read access
|
||||||
yield Zotero.DB.test();
|
yield Zotero.DB.test();
|
||||||
|
|
||||||
var dbfile = Zotero.getZoteroDatabase();
|
let dbfile = Zotero.DataDirectory.getDatabase();
|
||||||
|
|
||||||
// Tell any other Zotero instances to release their lock,
|
// Tell any other Zotero instances to release their lock,
|
||||||
// in case we lost the lock on the database (how?) and it's
|
// in case we lost the lock on the database (how?) and it's
|
||||||
// now open in two places at once
|
// now open in two places at once
|
||||||
Zotero.IPC.broadcast("releaseLock "+dbfile.persistentDescriptor);
|
Zotero.IPC.broadcast("releaseLock " + dbfile);
|
||||||
|
|
||||||
// Test write access on Zotero data directory
|
// Test write access on Zotero data directory
|
||||||
if (!dbfile.parent.isWritable()) {
|
if (!Zotero.File.pathToFile(OS.Path.dirname(dbfile)).isWritable()) {
|
||||||
var msg = 'Cannot write to ' + dbfile.parent.path + '/';
|
var msg = 'Cannot write to ' + OS.Path.dirname(dbfile) + '/';
|
||||||
}
|
}
|
||||||
// Test write access on Zotero database
|
// Test write access on Zotero database
|
||||||
else if (!dbfile.isWritable()) {
|
else if (!Zotero.File.pathToFile(dbfile).isWritable()) {
|
||||||
var msg = 'Cannot write to ' + dbfile.path;
|
var msg = 'Cannot write to ' + dbfile;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var msg = false;
|
var msg = false;
|
||||||
|
@ -897,9 +897,8 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
|
|
||||||
function getStorageDirectory(){
|
function getStorageDirectory(){
|
||||||
var file = Zotero.getZoteroDirectory();
|
var file = OS.Path.join(Zotero.DataDirectory.dir, 'storage');
|
||||||
|
file = Zotero.File.pathToFile(file);
|
||||||
file.append('storage');
|
|
||||||
Zotero.File.createDirectoryIfMissing(file);
|
Zotero.File.createDirectoryIfMissing(file);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -915,7 +914,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
* @return {nsIFile}
|
* @return {nsIFile}
|
||||||
*/
|
*/
|
||||||
this.getTempDirectory = function () {
|
this.getTempDirectory = function () {
|
||||||
var tmp = this.getZoteroDirectory();
|
var tmp = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
tmp.append('tmp');
|
tmp.append('tmp');
|
||||||
Zotero.File.createDirectoryIfMissing(tmp);
|
Zotero.File.createDirectoryIfMissing(tmp);
|
||||||
return tmp;
|
return tmp;
|
||||||
|
@ -923,7 +922,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
|
|
||||||
this.removeTempDirectory = function () {
|
this.removeTempDirectory = function () {
|
||||||
var tmp = this.getZoteroDirectory();
|
var tmp = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
tmp.append('tmp');
|
tmp.append('tmp');
|
||||||
if (tmp.exists()) {
|
if (tmp.exists()) {
|
||||||
try {
|
try {
|
||||||
|
@ -935,7 +934,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
|
|
||||||
this.getStylesDirectory = function () {
|
this.getStylesDirectory = function () {
|
||||||
var dir = this.getZoteroDirectory();
|
var dir = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
dir.append('styles');
|
dir.append('styles');
|
||||||
Zotero.File.createDirectoryIfMissing(dir);
|
Zotero.File.createDirectoryIfMissing(dir);
|
||||||
return dir;
|
return dir;
|
||||||
|
@ -943,7 +942,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
|
|
||||||
this.getTranslatorsDirectory = function () {
|
this.getTranslatorsDirectory = function () {
|
||||||
var dir = this.getZoteroDirectory();
|
var dir = Zotero.File.pathToFile(Zotero.DataDirectory.dir);
|
||||||
dir.append('translators');
|
dir.append('translators');
|
||||||
Zotero.File.createDirectoryIfMissing(dir);
|
Zotero.File.createDirectoryIfMissing(dir);
|
||||||
return dir;
|
return dir;
|
||||||
|
|
|
@ -516,13 +516,16 @@ function resetDB(options = {}) {
|
||||||
if (options.thisArg) {
|
if (options.thisArg) {
|
||||||
options.thisArg.timeout(60000);
|
options.thisArg.timeout(60000);
|
||||||
}
|
}
|
||||||
var db = Zotero.getZoteroDatabase();
|
var db = Zotero.DataDirectory.getDatabase();
|
||||||
return Zotero.reinit(function() {
|
return Zotero.reinit(
|
||||||
db.remove(false);
|
Zotero.Promise.coroutine(function* () {
|
||||||
_defaultGroup = null;
|
yield OS.File.remove(db);
|
||||||
}, false, options).then(function() {
|
_defaultGroup = null;
|
||||||
return Zotero.Schema.schemaUpdatePromise;
|
}),
|
||||||
});
|
false,
|
||||||
|
options
|
||||||
|
)
|
||||||
|
.then(() => Zotero.Schema.schemaUpdatePromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -78,7 +78,7 @@ describe("Zotero.Fulltext", function () {
|
||||||
yield Zotero.Fulltext.uninstallPDFTools();
|
yield Zotero.Fulltext.uninstallPDFTools();
|
||||||
assert.isFalse(Zotero.Fulltext.pdfInfoIsRegistered());
|
assert.isFalse(Zotero.Fulltext.pdfInfoIsRegistered());
|
||||||
|
|
||||||
var dataDir = Zotero.getZoteroDirectory().path;
|
var dataDir = Zotero.DataDirectory.dir;
|
||||||
var execFileName = Zotero.Fulltext.pdfInfoFileName;
|
var execFileName = Zotero.Fulltext.pdfInfoFileName;
|
||||||
var execPath = OS.Path.join(dataDir, execFileName);
|
var execPath = OS.Path.join(dataDir, execFileName);
|
||||||
var versionFileName = execFileName + '.version';
|
var versionFileName = execFileName + '.version';
|
||||||
|
|
|
@ -157,7 +157,7 @@ describe("Zotero.Sync.Storage.Local", function () {
|
||||||
yield OS.File.makeDir(
|
yield OS.File.makeDir(
|
||||||
OS.Path.join(dir, 'subdir'),
|
OS.Path.join(dir, 'subdir'),
|
||||||
{
|
{
|
||||||
from: Zotero.getZoteroDirectory().path,
|
from: Zotero.DataDirectory.dir,
|
||||||
unixMode: 0o755
|
unixMode: 0o755
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe("Zotero.Sync.Data.Local", function() {
|
||||||
|
|
||||||
|
|
||||||
describe("#checkUser()", function () {
|
describe("#checkUser()", function () {
|
||||||
var resetDataDirFile = OS.Path.join(Zotero.getZoteroDirectory().path, 'reset-data-directory');
|
var resetDataDirFile = OS.Path.join(Zotero.DataDirectory.dir, 'reset-data-directory');
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
sinon.stub(Zotero.Utilities.Internal, 'quitZotero');
|
sinon.stub(Zotero.Utilities.Internal, 'quitZotero');
|
||||||
|
|
Loading…
Add table
Reference in a new issue