Fix file sync error continuing to show after error had cleared
This commit is contained in:
parent
b208097a8e
commit
4a334fa7f7
4 changed files with 50 additions and 23 deletions
|
@ -104,9 +104,11 @@ Zotero.Sync.Storage.Queue.prototype.__defineSetter__('finishedRequests', functio
|
|||
var localChanges = this._localChanges;
|
||||
var remoteChanges = this._remoteChanges;
|
||||
var conflicts = this._conflicts.concat();
|
||||
var deferred = this._deferred;
|
||||
this._localChanges = false;
|
||||
this._remoteChanges = false;
|
||||
this._conflicts = [];
|
||||
this._deferred = null;
|
||||
|
||||
if (!this._error) {
|
||||
Zotero.debug("Resolving promise for queue " + this.name);
|
||||
|
@ -114,7 +116,7 @@ Zotero.Sync.Storage.Queue.prototype.__defineSetter__('finishedRequests', functio
|
|||
Zotero.debug(this._remoteChanges);
|
||||
Zotero.debug(this._conflicts);
|
||||
|
||||
this._deferred.resolve({
|
||||
deferred.resolve({
|
||||
libraryID: this.libraryID,
|
||||
type: this.type,
|
||||
localChanges: localChanges,
|
||||
|
@ -128,7 +130,7 @@ Zotero.Sync.Storage.Queue.prototype.__defineSetter__('finishedRequests', functio
|
|||
this._error = false;
|
||||
e.libraryID = this.libraryID;
|
||||
e.type = this.type;
|
||||
this._deferred.reject(e);
|
||||
deferred.reject(e);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -368,7 +370,12 @@ Zotero.Sync.Storage.Queue.prototype.addConflict = function (requestName, localDa
|
|||
|
||||
Zotero.Sync.Storage.Queue.prototype.error = function (e) {
|
||||
if (!this._error) {
|
||||
this._error = e;
|
||||
if (this.isRunning()) {
|
||||
this._error = e;
|
||||
}
|
||||
else {
|
||||
Zotero.debug("Queue " + this.name + " was no longer running -- not assigning error", 2);
|
||||
}
|
||||
}
|
||||
Zotero.debug(e, 1);
|
||||
this.stop();
|
||||
|
|
|
@ -43,6 +43,7 @@ Zotero.Sync.Storage.Request = function (name, callbacks) {
|
|||
|
||||
this._deferred = Q.defer();
|
||||
this._running = false;
|
||||
this._stopping = false;
|
||||
this._percentage = 0;
|
||||
this._remaining = null;
|
||||
this._maxSize = null;
|
||||
|
@ -222,16 +223,16 @@ Zotero.Sync.Storage.Request.prototype.start = function () {
|
|||
// This promise updates localChanges/remoteChanges on the queue
|
||||
self._deferred.resolve(results);
|
||||
})
|
||||
.fail(function (e) {
|
||||
.catch(function (e) {
|
||||
if (self._stopping) {
|
||||
Zotero.debug("Skipping error for stopping request " + self.name);
|
||||
return;
|
||||
}
|
||||
Zotero.debug(self.queue.Type + " request " + self.name + " failed");
|
||||
Zotero.debug(self._deferred);
|
||||
Zotero.debug(self._deferred.promise.isFulfilled());
|
||||
self._deferred.reject(e);
|
||||
Zotero.debug(self._deferred.promise.isFulfilled());
|
||||
Zotero.debug(self._deferred.promise.isRejected());
|
||||
})
|
||||
// Finish the request (and in turn the queue, if this is the last request)
|
||||
.fin(function () {
|
||||
.finally(function () {
|
||||
if (!self._finished) {
|
||||
self._finish();
|
||||
}
|
||||
|
@ -309,6 +310,8 @@ Zotero.Sync.Storage.Request.prototype.onProgress = function (channel, progress,
|
|||
*/
|
||||
Zotero.Sync.Storage.Request.prototype.stop = function () {
|
||||
if (this.channel) {
|
||||
this._stopping = true;
|
||||
|
||||
try {
|
||||
Zotero.debug("Stopping request '" + this.name + "'");
|
||||
this.channel.cancel(0x804b0002); // NS_BINDING_ABORTED
|
||||
|
@ -343,7 +346,7 @@ Zotero.Sync.Storage.Request.prototype._finish = function () {
|
|||
this.queue.updateProgress();
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.debug(e);
|
||||
Zotero.debug(e, 1);
|
||||
Components.utils.reportError(e);
|
||||
this._deferred.reject(e);
|
||||
throw e;
|
||||
|
|
|
@ -42,14 +42,19 @@ Zotero.Sync.Storage.WebDAV = (function () {
|
|||
* @param {Zotero.Item} item
|
||||
* @param {Function} callback Callback f(item, mdate)
|
||||
*/
|
||||
function getStorageModificationTime(item) {
|
||||
function getStorageModificationTime(item, request) {
|
||||
var funcName = "Zotero.Sync.Storage.WebDAV.getStorageModificationTime()";
|
||||
|
||||
var uri = getItemPropertyURI(item);
|
||||
|
||||
return Zotero.HTTP.promise(
|
||||
"GET", uri, { debug: true, successCodes: [200, 300, 404] }
|
||||
)
|
||||
return Zotero.HTTP.promise("GET", uri,
|
||||
{
|
||||
debug: true,
|
||||
successCodes: [200, 300, 404],
|
||||
requestObserver: function (xmlhttp) {
|
||||
request.setChannel(xmlhttp.channel);
|
||||
}
|
||||
})
|
||||
.then(function (req) {
|
||||
checkResponse(req);
|
||||
|
||||
|
@ -163,7 +168,7 @@ Zotero.Sync.Storage.WebDAV = (function () {
|
|||
var request = data.request;
|
||||
var item = Zotero.Sync.Storage.getItemFromRequestName(request.name);
|
||||
|
||||
return getStorageModificationTime(item)
|
||||
return getStorageModificationTime(item, request)
|
||||
.then(function (mdate) {
|
||||
if (!request.isRunning()) {
|
||||
Zotero.debug("Upload request '" + request.name
|
||||
|
@ -812,7 +817,7 @@ Zotero.Sync.Storage.WebDAV = (function () {
|
|||
}
|
||||
|
||||
// Retrieve modification time from server to store locally afterwards
|
||||
return getStorageModificationTime(item)
|
||||
return getStorageModificationTime(item, request)
|
||||
.then(function (mdate) {
|
||||
if (!request.isRunning()) {
|
||||
Zotero.debug("Download request '" + request.name
|
||||
|
|
|
@ -38,10 +38,17 @@ Zotero.Sync.Storage.ZFS = (function () {
|
|||
* @param {Zotero.Item} item
|
||||
* @param {Function} callback Callback f(item, etag)
|
||||
*/
|
||||
function getStorageFileInfo(item) {
|
||||
function getStorageFileInfo(item, request) {
|
||||
var funcName = "Zotero.Sync.Storage.ZFS.getStorageFileInfo()";
|
||||
|
||||
return Zotero.HTTP.promise("GET", getItemInfoURI(item), { successCodes: [200, 404], headers: _headers })
|
||||
return Zotero.HTTP.promise("GET", getItemInfoURI(item),
|
||||
{
|
||||
successCodes: [200, 404],
|
||||
headers: _headers,
|
||||
requestObserver: function (xmlhttp) {
|
||||
request.setChannel(xmlhttp.channel);
|
||||
}
|
||||
})
|
||||
.then(function (req) {
|
||||
if (req.status == 404) {
|
||||
return false;
|
||||
|
@ -72,10 +79,15 @@ Zotero.Sync.Storage.ZFS = (function () {
|
|||
|
||||
return info;
|
||||
})
|
||||
.fail(function (e) {
|
||||
.catch(function (e) {
|
||||
if (e instanceof Zotero.HTTP.UnexpectedStatusException) {
|
||||
var msg = "Unexpected status code " + e.xmlhttp.status
|
||||
+ " getting storage file info";
|
||||
if (e.xmlhttp.status == 0) {
|
||||
var msg = "Request cancelled getting storage file info";
|
||||
}
|
||||
else {
|
||||
var msg = "Unexpected status code " + e.xmlhttp.status
|
||||
+ " getting storage file info";
|
||||
}
|
||||
Zotero.debug(msg, 1);
|
||||
Zotero.debug(e.xmlhttp.responseText);
|
||||
Components.utils.reportError(msg);
|
||||
|
@ -102,7 +114,7 @@ Zotero.Sync.Storage.ZFS = (function () {
|
|||
|
||||
var request = data.request;
|
||||
var item = Zotero.Sync.Storage.getItemFromRequestName(request.name);
|
||||
return getStorageFileInfo(item)
|
||||
return getStorageFileInfo(item, request)
|
||||
.then(function (info) {
|
||||
if (request.isFinished()) {
|
||||
Zotero.debug("Upload request '" + request.name
|
||||
|
@ -694,7 +706,7 @@ Zotero.Sync.Storage.ZFS = (function () {
|
|||
}
|
||||
|
||||
// Retrieve file info from server to store locally afterwards
|
||||
return getStorageFileInfo(item)
|
||||
return getStorageFileInfo(item, request)
|
||||
.then(function (info) {
|
||||
if (!request.isRunning()) {
|
||||
Zotero.debug("Download request '" + request.name
|
||||
|
|
Loading…
Reference in a new issue