Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

DownloadUtils: XML refactor bug fixes.

* Handle errors properly.
* Remove all files when one of the extra items failed.
  • Loading branch information...
commit 346b04c8db656c90b4862e6d38c6d92fde5a34a0 1 parent 2f5042a
@littlebtc authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 modules/DownloadUtils.jsm
View
8 modules/DownloadUtils.jsm
@@ -435,6 +435,8 @@ DownloadUtils.nico.prototype = {
if (this._canceled) {
return;
}
+ this.cancelAllWorkers();
+ this.removeFiles();
showUtilsAlert('Download failed', 'Cannot get extra items');
this.callback("fail", {});
},
@@ -524,6 +526,11 @@ DownloadUtils.nico.prototype = {
var xhr = aEvent.target;
xhr.removeEventListener("load", this._xhrBoundedListeners.load, false);
if (this._canceled) { return; }
+ /* If it is not a successful HTTP request, reject promise */
+ if (xhr.status != 200) {
+ xhrDeferred.reject("httperror");
+ return;
+ }
var commentsDoc = xhr.responseXML;
var boonComment = Core.prefs.getBoolPref('boon_comment');
var replaceFilters = Core.prefs.getBoolPref('replace_filters');
@@ -576,6 +583,7 @@ DownloadUtils.nico.prototype = {
},
/* On XHR failure, remove listener and reject deferred promise */
onCommentXMLError: function(xhrDeferred, aEvent) {
+ var xhr = aEvent.target;
xhr.removeEventListener("error", this._xhrBoundedListeners.error, false);
xhrDeferred.reject("xhrError");
}
Please sign in to comment.
Something went wrong with that request. Please try again.