исправление при открытии торрента на странице
This commit is contained in:
parent
e6de177361
commit
671c836e24
6
index.js
6
index.js
@ -451,6 +451,7 @@ client.on('complete', function (metadata, infohash, rinfo) {
|
||||
filesArray.push(fileQ);
|
||||
}
|
||||
|
||||
let filesToAdd = filesArray.length;
|
||||
listenerMysql.query('SELECT count(*) as files_count FROM files WHERE hash = ?', [hash], function(err, rows) {
|
||||
const db_files = rows[0]['files_count'];
|
||||
if(db_files !== filesCount)
|
||||
@ -464,9 +465,12 @@ client.on('complete', function (metadata, infohash, rinfo) {
|
||||
listenerMysql.query('INSERT INTO files SET ?', file, function(err, result) {
|
||||
popDatabaseBalance();
|
||||
if(!result) {
|
||||
console.log(fileQ);
|
||||
console.log(file);
|
||||
console.error(err);
|
||||
}
|
||||
if(--filesToAdd === 0) {
|
||||
io.sockets.emit('filesReady', hash);
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
|
@ -141,7 +141,7 @@ export default class TorrentPage extends Page {
|
||||
value: value,
|
||||
});
|
||||
};
|
||||
componentDidMount() {
|
||||
getTorrentInfo() {
|
||||
window.torrentSocket.emit('torrent', this.props.hash, {files: true}, window.customLoader((data) => {
|
||||
if(data) {
|
||||
this.torrent = data
|
||||
@ -162,6 +162,17 @@ export default class TorrentPage extends Page {
|
||||
searchingIndicator: false
|
||||
});
|
||||
}));
|
||||
}
|
||||
componentDidMount() {
|
||||
this.getTorrentInfo();
|
||||
this.filesUpdated = (hash) => {
|
||||
if(this.props.hash != hash)
|
||||
return;
|
||||
|
||||
this.getTorrentInfo();
|
||||
}
|
||||
window.torrentSocket.on('filesReady', this.filesUpdated);
|
||||
|
||||
this.trackerUpdate = (info) => {
|
||||
if(this.props.hash != info.hash)
|
||||
return;
|
||||
@ -175,6 +186,8 @@ export default class TorrentPage extends Page {
|
||||
window.torrentSocket.on('trackerTorrentUpdate', this.trackerUpdate);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
if(this.filesUpdated)
|
||||
window.torrentSocket.off('filesReady', this.filesUpdated);
|
||||
if(this.trackerUpdate)
|
||||
window.torrentSocket.off('trackerTorrentUpdate', this.trackerUpdate);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user