Changeset 750
- Timestamp:
- 2008-01-18 20:14:29 (1 year ago)
- Files:
-
- trunk/chrome/content/dta/manager.js (modified) (18 diffs)
- trunk/chrome/content/dta/manager/prefs.js (modified) (1 diff)
- trunk/chrome/content/dta/manager/tree.js (modified) (1 diff)
- trunk/chrome/content/dta/manager/verificator.js (modified) (1 diff)
- trunk/defaults/preferences/dta.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/chrome/content/dta/manager.js
r749 r750 36 36 * 37 37 * ***** END LICENSE BLOCK ***** */ 38 39 const NS_ERROR_MODULE_NETWORK = 0x804B0000; 40 const NS_ERROR_BINDING_ABORTED = NS_ERROR_MODULE_NETWORK + 2; 41 const NS_ERROR_UNKNOWN_HOST = NS_ERROR_MODULE_NETWORK + 30; 42 const NS_ERROR_CONNECTION_REFUSED = NS_ERROR_MODULE_NETWORK + 13; 43 const NS_ERROR_NET_TIMEOUT = NS_ERROR_MODULE_NETWORK + 14; 44 const NS_ERROR_NET_RESET = NS_ERROR_MODULE_NETWORK + 20; 38 45 39 46 const Cc = Components.classes; … … 229 236 try { 230 237 this.refresh(); 231 238 239 if (Prefs.autoRetryInterval) { 240 for (let d in Tree.all) { 241 d.autoRetry(); 242 } 243 } 244 232 245 this._running.forEach( 233 246 function(i) { … … 237 250 if (d.resumable) { 238 251 d.pause(); 252 d.markAutoRetry(); 239 253 d.status = _("timeout"); 240 254 } … … 925 939 set conflicts(nv) { 926 940 if (typeof(nv) != 'number') { 927 return ;941 return this._conflicts; 928 942 } 929 943 this._conflicts = nv; … … 1067 1081 _status : '', 1068 1082 get status() { 1069 return this._status ;1083 return this._status + (this._autoRetryTime ? ' *' : ''); 1070 1084 }, 1071 1085 set status(nv) { … … 1103 1117 }, 1104 1118 1105 retry: function QI_retry() {1119 safeRetry: function QI_safeRetry() { 1106 1120 // reset flags 1107 1121 this.totalSize = this.partialSize = 0; … … 1429 1443 }, 1430 1444 sessionConnections: 0, 1445 _autoRetries: 0, 1446 _autoRetryTime: 0, 1447 markAutoRetry: function QI_markRetry() { 1448 if (!Prefs.autoRetryInterval || Prefs.maxAutoRetries <= this._autoRetries) { 1449 return; 1450 } 1451 this._autoRetryTime = Utils.getTimestamp(); 1452 Debug.logString("marked auto-retry: " + d); 1453 }, 1454 autoRetry: function QI_autoRetry() { 1455 if (!this._autoRetryTime || Utils.getTimestamp() - (Prefs.autoRetryInterval * 1000) < this._autoRetryTime) { 1456 return; 1457 } 1458 1459 this._autoRetryTime = 0; 1460 ++this._autoRetries; 1461 this.queue(); 1462 Debug.logString("Requeued due to auto-retry: " + d); 1463 }, 1464 queue: function QI_queue() { 1465 this.state = QUEUED; 1466 this.status = _("inqueue"); 1467 }, 1431 1468 resumeDownload: function QI_resumeDownload() { 1432 1469 Debug.logString("resumeDownload: " + this); … … 1437 1474 if (c1.complete && c2.complete) { 1438 1475 c1.merge(c2); 1439 d. chunks.splice(i + 1, 1);1476 d.splice(i + 1, 1); 1440 1477 } 1441 1478 } … … 1813 1850 Debug.logString("cancel"); 1814 1851 if (!aReason) { 1815 aReason = 0x804b0002; // NS_BINDING_ABORTED;1852 aReason = NS_ERROR_BINDING_ABORTED; 1816 1853 } 1817 1854 this._chan.cancel(aReason); … … 1990 2027 Debug.log("we got temp failure!", code); 1991 2028 d.pause(); 2029 d.markAutoRetry(); 1992 2030 d.status = code >= 500 ? _('temperror') : _('autherror'); 1993 2031 } … … 2011 2049 if (code != 206 && !this.isInfoGetter) { 2012 2050 Debug.log(d + ": Server returned a " + aChannel.responseStatus + " response instead of 206", this.isInfoGetter); 2013 Debug.log(c, this.url.url);2014 2051 2015 2052 d.resumable = false; … … 2024 2061 d.cancel(); 2025 2062 d.resumable = false; 2026 d. retry();2063 d.safeRetry(); 2027 2064 return false; 2028 2065 } … … 2038 2075 d.cancel(); 2039 2076 d.resumable = false; 2040 d. retry();2077 d.safeRetry(); 2041 2078 return false; 2042 2079 } … … 2101 2138 Debug.log(d + ": Server error or disconnection", "(type 1)"); 2102 2139 d.status = _("servererror"); 2140 d.markAutoRetry(); 2103 2141 d.pause(); 2104 2142 } … … 2247 2285 } 2248 2286 2287 if (aStatusCode == NS_ERROR_BINDING_ABORTED) { 2288 return; 2289 } 2290 2291 if (-1 != [ 2292 NS_ERROR_CONNECTION_REFUSED, 2293 NS_ERROR_UNKNOWN_HOST, 2294 NS_ERROR_NET_TIMEOUT, 2295 NS_ERROR_NET_RESET 2296 ].indexOf(aStatusCode)) { 2297 Debug.log(d + ": Server error or disconnection", "(type 3)"); 2298 d.pause(); 2299 d.status = _("servererror"); 2300 d.markAutoRetry(); 2301 return; 2302 } 2303 2249 2304 // routine for normal chunk 2250 2305 Debug.logString(d + ": Chunk " + c.start + "-" + c.end + " finished."); 2251 2306 2252 2307 // rude way to determine disconnection: if connection is closed before download is started we assume a server error/disconnection 2253 2308 if (c.starter && !shouldFinish && d.is(RUNNING)) { 2254 2309 if (!d.urlManager.markBad(this.url)) { 2255 2310 Debug.log(d + ": Server error or disconnection", "(type 2)"); 2311 d.pause(); 2256 2312 d.status = _("servererror"); 2257 d. pause();2313 d.markAutoRetry(); 2258 2314 return; 2259 2315 } … … 2261 2317 Debug.log("caught bad server", d.toString()); 2262 2318 d.cancel(); 2263 d. retry();2319 d.safeRetry(); 2264 2320 return; 2265 2321 } … … 2274 2330 if (d.resumable) { 2275 2331 d.pause(); 2332 d.markAutoRetry(); 2276 2333 d.status = _('errmismatchtitle'); 2277 2334 } … … 2288 2345 d.resumeDownload(); 2289 2346 } 2290 SessionManager.save(d);2347 //SessionManager.save(d); 2291 2348 }, 2292 2349 trunk/chrome/content/dta/manager/prefs.js
r740 r750 53 53 ['alertingSystem', 'alertbox', (SYSTEMSLASH == '\\') ? 1 : 0], 54 54 ['finishEvent', ''], 55 ['showTooltip', true] 55 ['showTooltip', true], 56 ['maxAutoRetries', 10], 57 ['autoRetryInterval', 0] 56 58 ], 57 59 trunk/chrome/content/dta/manager/tree.js
r740 r750 378 378 function(d) { 379 379 if (d.is(PAUSED, CANCELED)) { 380 d.state = QUEUED; 381 d.status = _("inqueue"); 380 d.queue(); 382 381 } 383 382 return true; trunk/chrome/content/dta/manager/verificator.js
r740 r750 103 103 var act = DTA_confirm(_('verifyerrortitle'), _('verifyerrortext'), _('retry'), _('delete'), _('keep')); 104 104 switch (act) { 105 case 0: this._delete(); this.download. retry(); return;105 case 0: this._delete(); this.download.safeRetry(); return; 106 106 case 1: this._delete(); this.download.cancel(); return; 107 107 } trunk/defaults/preferences/dta.js
r545 r750 64 64 pref("extensions.dta.lastalltabs", false); 65 65 pref("extensions.dta.rememberoneclick", false); 66 pref("extensions.dta.autoretryinterval", 0); 67 pref("extensions.dta.maxautoretries", 10); 66 68 67 69 // Seamonkey specific
