Changeset 556
- Timestamp:
- 2007-08-07 22:49:32 (1 year ago)
- Files:
-
- trunk/chrome/content/dta/manager.js (modified) (14 diffs)
- trunk/chrome/locale/en-US/manager.properties (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/chrome/content/dta/manager.js
r551 r556 43 43 var Ci = Components.interfaces; 44 44 } 45 if (!Exception) { 46 var Exception = Components.Exception; 47 } 45 48 46 49 const MIN_CHUNK_SIZE = 700 * 1024; … … 622 625 } 623 626 Debug.dump(x + " missing"); 624 throw new Components.Exception(x + " is missing");627 throw new Exception(x + " is missing"); 625 628 } 626 629 // header is there, but differs 627 630 else if (this[x] != v[x]) { 628 631 Debug.dump(x + " nm: [" + this[x] + "] [" + v[x] + "]"); 629 throw new Components.Exception("Header " + x + " doesn't match");632 throw new Exception("Header " + x + " doesn't match"); 630 633 } 631 634 } … … 713 716 } 714 717 } 715 throw new Components.Exception("No Date registered");718 throw new Exception("No Date registered"); 716 719 } 717 720 }; … … 1123 1126 // small validation. Around epoche? More than a month in future? 1124 1127 if (time < 2 || time > Date.now() + 30 * 86400000) { 1125 throw new Components.Exception("invalid date encountered: " + time + ", will not set it");1128 throw new Exception("invalid date encountered: " + time + ", will not set it"); 1126 1129 } 1127 1130 // have to unwrap … … 1454 1457 } 1455 1458 1456 var Chunk = function(download, start, end, written) {1459 function Chunk(download, start, end, written) { 1457 1460 // saveguard against null or strings and such 1458 1461 this._written = written > 0 ? written : 0; … … 1461 1464 this.end = end; 1462 1465 this._parent = download; 1466 this._sessionbytes = 0; 1463 1467 } 1464 1468 … … 1504 1508 }, 1505 1509 open: function CH_open() { 1510 this._sessionBytes = 0; 1506 1511 let file = this.parent.tmpFile.clone(); 1507 1512 if (!file.parent.exists()) { … … 1535 1540 } 1536 1541 }, 1542 rollback: function CH_rollback() { 1543 if (!this._sessionBytes || this._sessionBytes > this._written) { 1544 return; 1545 } 1546 this._written -= this._sessionBytes; 1547 this._sessionBytes = 0; 1548 }, 1537 1549 cancel: function CH_cancel() { 1538 1550 this.running = false; … … 1557 1569 } 1558 1570 if (bytes < 0) { 1559 throw new Components.Exception("bytes negative");1571 throw new Exception("bytes negative"); 1560 1572 } 1561 1573 // we're using nsIFileOutputStream … … 1564 1576 } 1565 1577 this._written += bytes; 1578 this._sessionBytes += bytes; 1566 1579 1567 1580 this.parent.timeLastProgress = Utils.getTimestamp(); 1568 1581 1569 1582 return bytes; 1570 } catch (ex) { 1583 } 1584 catch (ex) { 1571 1585 Debug.dump('write: ' + this.parent.tmpFile.path, ex); 1572 1586 throw ex; … … 1795 1809 d.chunks[found].end = c.end; 1796 1810 if (--d.maxChunks == 1) { 1797 d.resumable = false;1811 //d.resumable = false; 1798 1812 } 1799 1813 d.chunks = d.chunks.filter(function(ch) { return ch != c; }); … … 1840 1854 } 1841 1855 1842 1843 1856 if (code >= 400) { 1844 1857 if (!this.handleError()) { 1845 1858 Debug.dump("handleError: Cannot recover from problem!", code); 1846 var file = d.fileName.length > 50 ? d.fileName.substring(0, 50) + "..." : d.fileName; 1847 code = Utils.formatNumber(code, 3); 1848 d.fail( 1849 _("error", [code]), 1850 _("failed", [file]) + " " + _("sra", [code]) + ": " + status, 1851 _("error", [code]) 1852 ); 1859 if ([401, 402, 407, 500, 502, 503, 504].indexOf(code) != -1) { 1860 Debug.dump("we got temp failure!", code); 1861 d.pause(); 1862 d.status = code >= 500 ? _('temperror') : _('autherror'); 1863 } 1864 else { 1865 var file = d.fileName.length > 50 ? d.fileName.substring(0, 50) + "..." : d.fileName; 1866 code = Utils.formatNumber(code, 3); 1867 d.fail( 1868 _("error", [code]), 1869 _("failed", [file]) + " " + _("sra", [code]) + ": " + status, 1870 _("error", [code]) 1871 ); 1872 } 1873 // any data that we got over this channel should be considered "corrupt" 1874 c.rollback(); 1853 1875 SessionManager.save(d); 1854 1876 } … … 1952 1974 // hack: determine if we are a multi-part chunk, 1953 1975 // if so something bad happened, 'cause we aren't supposed to be multi-part 1954 if (c.start != 0 ) {1976 if (c.start != 0 && d.is(RUNNING)) { 1955 1977 if (!this.handleError()) { 1956 1978 Debug.dump(d + ": Server error or disconnection (type 1)"); … … 2114 2136 2115 2137 // rude way to determine disconnection: if connection is closed before download is started we assume a server error/disconnection 2116 if (c.starter && !shouldFinish ) {2138 if (c.starter && !shouldFinish && d.is(RUNNING)) { 2117 2139 if (!d.urlManager.markBad(this.url)) { 2118 Debug.dump(d + ": Server error or disconnection (type 1)");2140 Debug.dump(d + ": Server error or disconnection (type 2)"); 2119 2141 d.status = _("servererror"); 2120 2142 d.speed = ''; trunk/chrome/locale/en-US/manager.properties
r537 r556 21 21 failed=Failed 22 22 servererror=Server error 23 autherror=Authentication failed 24 temperror=Temporary error 23 25 sra=Server returned a %S error 24 26 errmismatchtitle=Size mismatch
