fix(downloading): always show downloading on list even if download not started

This commit is contained in:
Alexey Kasyanchuk
2018-06-26 19:31:18 +03:00
parent c321286d6c
commit 6bd4d69e4c
3 changed files with 41 additions and 37 deletions

View File

@ -585,31 +585,33 @@ module.exports = async ({
return
}
torrentClient.add(magnet, {path: config.client.downloadPath}, (torrent) =>{
torrentClientHashMap[torrent.infoHash] = magnet
torrent.torrentObject = torrentObject
const torrent = torrentClient.add(magnet, {path: config.client.downloadPath})
torrentClientHashMap[torrent.infoHash] = magnet
torrent.torrentObject = torrentObject
torrent.on('torrent', () => {
console.log('start downloading', torrent.infoHash)
send('downloading', torrent.infoHash)
})
torrent.on('done', () => {
console.log('download done', torrent.infoHash)
delete torrentClientHashMap[torrent.infoHash]
send('downloadDone', torrent.infoHash)
})
torrent.on('done', () => {
console.log('download done', torrent.infoHash)
delete torrentClientHashMap[torrent.infoHash]
send('downloadDone', torrent.infoHash)
})
let now = Date.now()
torrent.on('download', (bytes) => {
if(Date.now() - now < 100)
return
now = Date.now()
let now = Date.now()
torrent.on('download', (bytes) => {
if(Date.now() - now < 100)
return
now = Date.now()
send('downloadProgress', torrent.infoHash, {
received: bytes,
downloaded: torrent.downloaded,
downloadSpeed: torrent.downloadSpeed,
progress: torrent.progress,
timeRemaining: torrent.timeRemaining
})
send('downloadProgress', torrent.infoHash, {
received: bytes,
downloaded: torrent.downloaded,
downloadSpeed: torrent.downloadSpeed,
progress: torrent.progress,
timeRemaining: torrent.timeRemaining
})
})
});