(trunk web) better bootstrapping when first loading all the torrents.

This commit is contained in:
Jordan Lee 2011-08-26 23:34:43 +00:00
parent 8949fbb01c
commit 4517155353
2 changed files with 12 additions and 8 deletions

View File

@ -208,7 +208,7 @@ Torrent.prototype =
getId: function() { return this.fields.id; },
getLeftUntilDone: function() { return this.fields.leftUntilDone; },
getMetadataPercentComplete: function() { return this.fields.metadataPercentComplete; },
getName: function() { return this.fields.name; },
getName: function() { return this.fields.name || 'Unknown'; },
getPeers: function() { return this.fields.peers; },
getPeersConnected: function() { return this.fields.peersConnected; },
getPeersGettingFromUs: function() { return this.fields.peersGettingFromUs; },
@ -255,7 +255,9 @@ Torrent.prototype =
case Torrent._StatusDownload: return 'Downloading';
case Torrent._StatusSeedWait: return 'Queued for seeding';
case Torrent._StatusSeed: return 'Seeding';
default: return 'error';
case null:
case undefined: return 'Unknown';
default: return 'Error';
}
},
seedRatioLimit: function(controller){
@ -281,7 +283,7 @@ Torrent.prototype =
getCollatedName: function() {
var f = this.fields;
if (!f.collatedName) {
var name = this.getName();
var name = this.fields.name;
if (name)
f.collatedName = name.toLowerCase();
}

View File

@ -1047,7 +1047,7 @@ Transmission.prototype =
updateFromTorrentGet: function(updates, removed_ids)
{
var new_ids = [];
var needinfo = [];
for (var i=0, o; o=updates[i]; ++i) {
var t;
@ -1058,14 +1058,15 @@ Transmission.prototype =
var tr = this;
t = tr._torrents[id] = new Torrent(o);
$(t).bind('dataChanged',function(ev) {tr.onTorrentChanged(ev);});
new_ids.push(id);
if(!('name' in t.fields) || !('status' in t.fields)) // missing some fields...
needinfo.push(id);
}
}
if (new_ids.length) {
if (needinfo.length) {
// whee, new torrents! get their initial information.
var fields = ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats);
this.remote.updateTorrents(new_ids, fields, this.updateFromTorrentGet, this);
this.remote.updateTorrents(needinfo, fields, this.updateFromTorrentGet, this);
this.refilterSoon();
}
@ -1091,7 +1092,8 @@ Transmission.prototype =
{
// to bootstrap, we only need to ask for the servers's torrents' ids.
// updateFromTorrentGet() automatically asks for the rest of the info when it gets a new id.
this.remote.updateTorrents(null, ['id'], this.updateFromTorrentGet, this);
var fields = ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats);
this.remote.updateTorrents(null, fields, this.updateFromTorrentGet, this);
},
refreshInspectorTorrents: function(full)