Bug 814099 - Paused downloads don't behave properly in Downloads Panel after the session is restored. r=mak.

This commit is contained in:
Mike Conley 2012-11-22 14:54:51 -05:00
Родитель 07911c72d9
Коммит 32265fdca3
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -753,7 +753,21 @@ const DownloadsData = {
dataItem.startTime = Math.round(aDownload.startTime / 1000);
dataItem.currBytes = aDownload.amountTransferred;
dataItem.maxBytes = aDownload.size;
dataItem.download = aDownload;
// When a download is retried, we create a different download object from
// the database with the same ID as before. This means that the nsIDownload
// that the dataItem holds might now need updating.
//
// It's possible, however, that dataItem.download is still a lazy getter
// if we never read the download property after initializing the dataItem
// from a data row in the downloads database. In that case, we can leave
// it alone - the next time the download property is accessed, the right
// download object will be retrieved.
let downloadIsGetter = Object.getOwnPropertyDescriptor(dataItem, "download")
.value === undefined;
if (!downloadIsGetter) {
dataItem.download = aDownload;
}
this._views.forEach(
function (view) view.getViewItem(dataItem).onStateChange()