Skip to content

Commit

Permalink
Improved fixing HEAD~2
Browse files Browse the repository at this point in the history
  • Loading branch information
ccloli committed Jun 1, 2016
1 parent 2f5045d commit 281a9f0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ function updateTotalStatus(){

// Updated on 1.19: Now the index argument is the page's number - 1 (original is page's number)
function failedFetching(index, nodeList, forced){
if (imageData[index] instanceof ArrayBuffer) return;
if (!isDownloading || imageData[index] instanceof ArrayBuffer) return;
// Temporarily fixes #31
if (typeof fetchThread[index] !== 'undefined' && 'abort' in fetchThread[index]) fetchThread[index].abort();
console.error('[EHD] Index >', index + 1, ' | RealIndex >', imageList[index]['realIndex'], ' | Name >', imageList[index]['imageName'], ' | RetryCount >', retryCount[index], ' | DownloadedCount >', downloadedCount, ' | FetchCount >', fetchCount, ' | FailedCount >', failedCount);
Expand Down Expand Up @@ -728,7 +728,7 @@ function fetchOriginalImage(index, nodeList) {
ehDownloadDialog.scrollTop = ehDownloadDialog.scrollHeight;

var zeroSpeedHandler = function(res){
if (imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31
if (!isDownloading || imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31

updateProgress(nodeList, { progressText: '0 KB/s' });

Expand All @@ -738,7 +738,7 @@ function fetchOriginalImage(index, nodeList) {
};

var expiredSpeedHandler = function(res){
if (imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31
if (!isDownloading || imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31

if (typeof fetchThread[index] !== 'undefined' && 'abort' in fetchThread[index]) fetchThread[index].abort();

Expand Down Expand Up @@ -829,7 +829,7 @@ function fetchOriginalImage(index, nodeList) {
//console.log('[EHD-Debug]', index, 'Load Finished!', new Date().getTime());

removeTimerHandler();
if (imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31
if (!isDownloading || imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31

// cache them to reduce waiting time and CPU usage on Chrome with Tampermonkey
// (Tampermonkey uses a dirty way to give res.response, transfer string to arraybuffer every time)
Expand Down Expand Up @@ -1039,7 +1039,7 @@ function fetchOriginalImage(index, nodeList) {
},
onerror: function(res){
removeTimerHandler();
if (imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31
if (!isDownloading || imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31

console.log('[EHD] #' + (index + 1) + ': Network Error');
console.log('[EHD] #' + (index + 1) + ': RealIndex >', imageList[index]['realIndex'], ' | ReadyState >', res.readyState, ' | Status >', res.status, ' | StatusText >', res.statusText + '\nResposeHeaders >' + res.responseHeaders);
Expand All @@ -1061,7 +1061,7 @@ function fetchOriginalImage(index, nodeList) {
},
ontimeout: function(res){
removeTimerHandler();
if (imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31
if (!isDownloading || imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31

console.log('[EHD] #' + (index + 1) + ': Timed Out');
console.log('[EHD] #' + (index + 1) + ': RealIndex >', imageList[index]['realIndex'], ' | ReadyState >', res.readyState, ' | Status >', res.status, ' | StatusText >', res.statusText + '\nResposeHeaders >' + res.responseHeaders);
Expand All @@ -1085,7 +1085,7 @@ function fetchOriginalImage(index, nodeList) {

if (!nodeList.status.dataset.initedAbort) {
nodeList.abort.addEventListener('click', function(){
if (imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31
if (!isDownloading || imageData[index] instanceof ArrayBuffer) return; // Temporarily fixes #31

if (typeof fetchThread[index] !== 'undefined' && 'abort' in fetchThread[index]) fetchThread[index].abort();
removeTimerHandler();
Expand Down

0 comments on commit 281a9f0

Please sign in to comment.