Merge branch '4.0'
Conflicts: chrome/content/zotero/xpcom/db.js chrome/content/zotero/xpcom/zotero.js install.rdf update.rdf
This commit is contained in:
commit
b2d46ee2fe
|
@ -1025,8 +1025,11 @@ Zotero.DBConnection.prototype.checkException = function (e) {
|
||||||
|
|
||||||
Zotero.DBConnection.prototype.closeDatabase = function () {
|
Zotero.DBConnection.prototype.closeDatabase = function () {
|
||||||
if(this._connection) {
|
if(this._connection) {
|
||||||
this._connection.asyncClose();
|
var deferred = Q.defer();
|
||||||
return true;
|
this._connection.asyncClose(deferred.resolve);
|
||||||
|
return deferred.promise;
|
||||||
|
} else {
|
||||||
|
return Q();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -811,8 +811,12 @@ Zotero.Sync.Storage = new function () {
|
||||||
var numItems = items.length;
|
var numItems = items.length;
|
||||||
var updatedStates = {};
|
var updatedStates = {};
|
||||||
|
|
||||||
// OS.File didn't work reliably before Firefox 23, so use the old code
|
// OS.File didn't work reliably before Firefox 23, and on Windows it returns
|
||||||
if (Zotero.platformMajorVersion < 23) {
|
// the access time instead of the modification time until Firefox 25
|
||||||
|
// (https://bugzilla.mozilla.org/show_bug.cgi?id=899436),
|
||||||
|
// so use the old code
|
||||||
|
if (Zotero.platformMajorVersion < 23
|
||||||
|
|| (Zotero.isWin && Zotero.platformMajorVersion < 25)) {
|
||||||
Zotero.debug("Performing synchronous file update check");
|
Zotero.debug("Performing synchronous file update check");
|
||||||
|
|
||||||
for each(var item in items) {
|
for each(var item in items) {
|
||||||
|
@ -935,10 +939,10 @@ Zotero.Sync.Storage = new function () {
|
||||||
throw new Task.Result(changed);
|
throw new Task.Result(changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/osfile.jsm")
|
Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
let checkItems = function () {
|
let checkItems = function () {
|
||||||
if (!items.length) return;
|
if (!items.length) return Q();
|
||||||
|
|
||||||
//Zotero.debug("Memory usage: " + memmgr.resident);
|
//Zotero.debug("Memory usage: " + memmgr.resident);
|
||||||
|
|
||||||
|
@ -948,6 +952,11 @@ Zotero.Sync.Storage = new function () {
|
||||||
//Zotero.debug("Checking attachment file for item " + lk);
|
//Zotero.debug("Checking attachment file for item " + lk);
|
||||||
|
|
||||||
let nsIFile = item.getFile(row, true);
|
let nsIFile = item.getFile(row, true);
|
||||||
|
if (!nsIFile) {
|
||||||
|
Zotero.debug("Marking pathless attachment " + lk + " as in-sync");
|
||||||
|
updatedStates[item.id] = Zotero.Sync.Storage.SYNC_STATE_IN_SYNC;
|
||||||
|
return checkItems();
|
||||||
|
}
|
||||||
let file = null;
|
let file = null;
|
||||||
return Q(OS.File.open(nsIFile.path))
|
return Q(OS.File.open(nsIFile.path))
|
||||||
.then(function (promisedFile) {
|
.then(function (promisedFile) {
|
||||||
|
@ -1022,8 +1031,13 @@ Zotero.Sync.Storage = new function () {
|
||||||
return Zotero.Utilities.Internal.md5Async(file)
|
return Zotero.Utilities.Internal.md5Async(file)
|
||||||
.then(function (fileHash) {
|
.then(function (fileHash) {
|
||||||
if (row.hash && row.hash == fileHash) {
|
if (row.hash && row.hash == fileHash) {
|
||||||
|
// We have to close the file before modifying it from the main
|
||||||
|
// thread (at least on Windows, where assigning lastModifiedTime
|
||||||
|
// throws an NS_ERROR_FILE_IS_LOCKED otherwise)
|
||||||
|
return Q(file.close())
|
||||||
|
.then(function () {
|
||||||
Zotero.debug("Mod time didn't match (" + fmtime + "!=" + mtime + ") "
|
Zotero.debug("Mod time didn't match (" + fmtime + "!=" + mtime + ") "
|
||||||
+ "but hash did for " + file.leafName + " for item " + lk
|
+ "but hash did for " + nsIFile.leafName + " for item " + lk
|
||||||
+ " -- updating file mod time");
|
+ " -- updating file mod time");
|
||||||
try {
|
try {
|
||||||
nsIFile.lastModifiedTime = row.mtime;
|
nsIFile.lastModifiedTime = row.mtime;
|
||||||
|
@ -1031,7 +1045,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
catch (e) {
|
catch (e) {
|
||||||
Zotero.File.checkFileAccessError(e, nsIFile, 'update');
|
Zotero.File.checkFileAccessError(e, nsIFile, 'update');
|
||||||
}
|
}
|
||||||
return;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark file for upload
|
// Mark file for upload
|
||||||
|
@ -1048,20 +1062,27 @@ Zotero.Sync.Storage = new function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(function (e) {
|
||||||
if (e instanceof OS.File.Error && e.becauseNoSuchFile) {
|
if (e instanceof OS.File.Error &&
|
||||||
|
(e.becauseNoSuchFile
|
||||||
|
// This can happen if a path is too long on Windows,
|
||||||
|
// e.g. a file is being accessed on a VM through a share
|
||||||
|
// (and probably in other cases).
|
||||||
|
|| (e.winLastError && e.winLastError == 3))) {
|
||||||
Zotero.debug("Marking attachment " + lk + " as missing");
|
Zotero.debug("Marking attachment " + lk + " as missing");
|
||||||
updatedStates[item.id] = Zotero.Sync.Storage.SYNC_STATE_TO_DOWNLOAD;
|
updatedStates[item.id] = Zotero.Sync.Storage.SYNC_STATE_TO_DOWNLOAD;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e instanceof OS.File.Error && e.becauseClosed) {
|
if (e instanceof OS.File.Error) {
|
||||||
|
if (e.becauseClosed) {
|
||||||
Zotero.debug("File was closed", 2);
|
Zotero.debug("File was closed", 2);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Zotero.debug(e);
|
Zotero.debug(e);
|
||||||
Zotero.debug(e.toString());
|
Zotero.debug(e.toString());
|
||||||
|
throw new Error("Error for operation '" + e.operation + "' for " + nsIFile.path);
|
||||||
}
|
}
|
||||||
throw new Error("Error " + e.operation + " " + nsIFile.path);
|
|
||||||
|
throw e;
|
||||||
})
|
})
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return checkItems();
|
return checkItems();
|
||||||
|
|
|
@ -405,7 +405,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register shutdown handler to call Zotero.shutdown()
|
// Register shutdown handler to call Zotero.shutdown()
|
||||||
var _shutdownObserver = {observe:Zotero.shutdown};
|
var _shutdownObserver = {observe:function() { Zotero.shutdown().done() }};
|
||||||
Services.obs.addObserver(_shutdownObserver, "quit-application", false);
|
Services.obs.addObserver(_shutdownObserver, "quit-application", false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -758,7 +758,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.shutdown = function (subject, topic, data) {
|
this.shutdown = function() {
|
||||||
Zotero.debug("Shutting down Zotero");
|
Zotero.debug("Shutting down Zotero");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -786,17 +786,17 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
Components.utils.forceGC();
|
Components.utils.forceGC();
|
||||||
|
|
||||||
// unlock DB
|
// unlock DB
|
||||||
Zotero.DB.closeDatabase();
|
return Zotero.DB.closeDatabase().then(function() {
|
||||||
|
|
||||||
// broadcast that DB lock has been released
|
// broadcast that DB lock has been released
|
||||||
Zotero.IPC.broadcast("lockReleased");
|
Zotero.IPC.broadcast("lockReleased");
|
||||||
}
|
});
|
||||||
} catch(e) {
|
|
||||||
Zotero.debug(e);
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return Q();
|
||||||
|
} catch(e) {
|
||||||
|
Zotero.debug(e);
|
||||||
|
return Q.reject(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -164,11 +164,11 @@ ZoteroContext.prototype = {
|
||||||
*/
|
*/
|
||||||
"switchConnectorMode":function(isConnector) {
|
"switchConnectorMode":function(isConnector) {
|
||||||
if(isConnector !== this.isConnector) {
|
if(isConnector !== this.isConnector) {
|
||||||
zContext.Zotero.shutdown();
|
zContext.Zotero.shutdown().then(function() {
|
||||||
|
|
||||||
// create a new zContext
|
// create a new zContext
|
||||||
makeZoteroContext(isConnector);
|
makeZoteroContext(isConnector);
|
||||||
zContext.Zotero.init();
|
zContext.Zotero.init();
|
||||||
|
}).done();
|
||||||
}
|
}
|
||||||
|
|
||||||
return zContext;
|
return zContext;
|
||||||
|
@ -292,16 +292,11 @@ function ZoteroService() {
|
||||||
try {
|
try {
|
||||||
zContext.Zotero.init();
|
zContext.Zotero.init();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
if(e === "ZOTERO_SHOULD_START_AS_CONNECTOR") {
|
|
||||||
// if Zotero should start as a connector, reload it
|
// if Zotero should start as a connector, reload it
|
||||||
zContext.Zotero.shutdown();
|
zContext.Zotero.shutdown().then(function() {
|
||||||
makeZoteroContext(true);
|
makeZoteroContext(true);
|
||||||
zContext.Zotero.init();
|
zContext.Zotero.init();
|
||||||
} else {
|
}).done();
|
||||||
dump(e.toSource());
|
|
||||||
Components.utils.reportError(e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isFirstLoadThisSession = false; // no longer first load
|
isFirstLoadThisSession = false; // no longer first load
|
||||||
|
|
2
styles
2
styles
|
@ -1 +1 @@
|
||||||
Subproject commit d7eaec6c1e691b661facc0b4db491a1052c3bf1a
|
Subproject commit 01e0f42aee7595b7cccafe731de57f277c2b76df
|
Loading…
Reference in New Issue
Block a user