mirror of
https://github.com/transmission/transmission.git
synced 2025-12-27 05:38:40 +00:00
(trunk web) #2772 "Even after a magnet link gets metainfo, the Web GUI doesn't use that metainfo" -- fixed in trunk for 1.90
This commit is contained in:
@@ -33,8 +33,11 @@ Torrent._TrackerQueued = 2;
|
||||
Torrent._TrackerActive = 3;
|
||||
|
||||
|
||||
Torrent._StaticFields = [ 'addedDate', 'comment', 'creator', 'dateCreated',
|
||||
'hashString', 'id', 'isPrivate', 'name', 'totalSize', 'pieceCount', 'pieceSize' ]
|
||||
Torrent._StaticFields = [ 'hashString', 'id' ]
|
||||
|
||||
Torrent._MetaDataFields = [ 'addedDate', 'comment', 'creator', 'dateCreated',
|
||||
'isPrivate', 'name', 'totalSize', 'pieceCount', 'pieceSize' ]
|
||||
|
||||
Torrent._DynamicFields = [ 'downloadedEver', 'error', 'errorString', 'eta',
|
||||
'haveUnchecked', 'haveValid', 'leftUntilDone', 'metadataPercentComplete', 'peersConnected',
|
||||
'peersGettingFromUs', 'peersSendingToUs', 'rateDownload', 'rateUpload',
|
||||
@@ -43,26 +46,41 @@ Torrent._DynamicFields = [ 'downloadedEver', 'error', 'errorString', 'eta',
|
||||
|
||||
Torrent.prototype =
|
||||
{
|
||||
initMetaData: function( data ) {
|
||||
this._date = data.addedDate;
|
||||
this._comment = data.comment;
|
||||
this._creator = data.creator;
|
||||
this._creator_date = data.dateCreated;
|
||||
this._is_private = data.isPrivate;
|
||||
this._name = data.name;
|
||||
this._name_lc = this._name.toLowerCase( );
|
||||
this._size = data.totalSize;
|
||||
this._pieceCount = data.pieceCount;
|
||||
this._pieceSize = data.pieceSize;
|
||||
|
||||
if( data.files ) {
|
||||
for( var i=0, row; row=data.files[i]; ++i ) {
|
||||
this._file_model[i] = {
|
||||
'index': i,
|
||||
'torrent': this,
|
||||
'length': row.length,
|
||||
'name': row.name
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
initialize: function( transferListParent, fileListParent, controller, data) {
|
||||
this._id = data.id;
|
||||
this._is_private = data.isPrivate;
|
||||
this._hashString = data.hashString;
|
||||
this._date = data.addedDate;
|
||||
this._size = data.totalSize;
|
||||
this._pieceCount = data.pieceCount;
|
||||
this._pieceSize = data.pieceSize;
|
||||
this._comment = data.comment;
|
||||
this._creator = data.creator;
|
||||
this._creator_date = data.dateCreated;
|
||||
this._sizeWhenDone = data.sizeWhenDone;
|
||||
this._name = data.name;
|
||||
this._name_lc = this._name.toLowerCase( );
|
||||
this._trackerStats = this.buildTrackerStats(data.trackerStats);
|
||||
this._file_model = [ ];
|
||||
this._file_view = [ ];
|
||||
this.initMetaData( data );
|
||||
|
||||
// Create a new <li> element
|
||||
var top_e = document.createElement( 'li' );
|
||||
@@ -129,17 +147,6 @@ Torrent.prototype =
|
||||
|
||||
this.initializeTorrentFilesInspectorGroup( fileListParent );
|
||||
|
||||
if( data.files ) {
|
||||
for( var i=0, row; row=data.files[i]; ++i ) {
|
||||
this._file_model[i] = {
|
||||
'index': i,
|
||||
'torrent': this,
|
||||
'length': row.length,
|
||||
'name': row.name
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Update all the labels etc
|
||||
this.refresh(data);
|
||||
|
||||
@@ -341,6 +348,13 @@ Torrent.prototype =
|
||||
* I N T E R F A C E F U N C T I O N S
|
||||
*
|
||||
*--------------------------------------------*/
|
||||
|
||||
refreshMetaData: function(data) {
|
||||
this.initMetaData( data );
|
||||
this.ensureFileListExists();
|
||||
this.refreshFileView();
|
||||
this.refreshHTML( );
|
||||
},
|
||||
|
||||
refresh: function(data) {
|
||||
this.refreshData( data );
|
||||
@@ -350,7 +364,11 @@ Torrent.prototype =
|
||||
/*
|
||||
* Refresh display
|
||||
*/
|
||||
refreshData: function(data) {
|
||||
refreshData: function(data)
|
||||
{
|
||||
if( this.needsMetaData() && ( data.metadataPercentComplete >= 1 ) )
|
||||
transmission.refreshMetaData( [ this._id ] );
|
||||
|
||||
this._completed = data.haveUnchecked + data.haveValid;
|
||||
this._verified = data.haveValid;
|
||||
this._leftUntilDone = data.leftUntilDone;
|
||||
|
||||
@@ -1358,6 +1358,27 @@ Transmission.prototype =
|
||||
this.setFilter( Prefs._FilterAll );
|
||||
},
|
||||
|
||||
refreshMetaData: function(ids) {
|
||||
var tr = this;
|
||||
this.remote.getMetaDataFor(ids, function(active, removed){ tr.updateMetaData(active); });
|
||||
},
|
||||
|
||||
updateMetaData: function( torrents )
|
||||
{
|
||||
var tr = this;
|
||||
var refresh_files_for = [ ];
|
||||
jQuery.each( torrents, function( ) {
|
||||
var t = tr._torrents[ this.id ];
|
||||
if( t ) {
|
||||
t.refreshMetaData( this );
|
||||
if( t.isSelected( ) )
|
||||
refresh_files_for.push( t.id( ) );
|
||||
}
|
||||
} );
|
||||
if( refresh_files_for.length > 0 )
|
||||
tr.remote.loadTorrentFiles( refresh_files_for );
|
||||
},
|
||||
|
||||
refreshTorrents: function(ids) {
|
||||
var tr = this;
|
||||
if (!ids)
|
||||
|
||||
@@ -112,7 +112,24 @@ TransmissionRemote.prototype =
|
||||
var o = {
|
||||
method: 'torrent-get',
|
||||
arguments: {
|
||||
fields: Torrent._StaticFields.concat(Torrent._DynamicFields, [ 'files', 'fileStats' ])
|
||||
fields: Torrent._StaticFields.concat( Torrent._MetaDataFields,
|
||||
Torrent._DynamicFields,
|
||||
[ 'files', 'fileStats' ] )
|
||||
}
|
||||
};
|
||||
|
||||
if(torrent_ids)
|
||||
o.arguments.ids = torrent_ids;
|
||||
|
||||
this.sendRequest( o, function(data){ callback(data.arguments.torrents)} );
|
||||
},
|
||||
|
||||
getMetaDataFor: function(torrent_ids, callback) {
|
||||
var o = {
|
||||
method: 'torrent-get',
|
||||
arguments: {
|
||||
fields: Torrent._StaticFields.concat( Torrent._MetaDataFields,
|
||||
[ 'files', 'fileStats' ] )
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user