fix(downloading): fix recheck progress indication on start and finish
This commit is contained in:
parent
ea07872137
commit
1a23973ba2
@ -311,7 +311,7 @@ export default class Torrent extends Component {
|
||||
</div>
|
||||
}
|
||||
{
|
||||
this.state.downloading
|
||||
(this.state.downloading || this.state.downloaded)
|
||||
&&
|
||||
<div className='row w100p inline text-nowrap' style={{maxWidth: 580}}>
|
||||
<div style={{marginRight: 5, color: 'rgb(0, 188, 212)'}}>{__('downloading')}: </div>
|
||||
|
@ -591,22 +591,7 @@ module.exports = async ({
|
||||
torrentClientHashMap[torrent.infoHash] = magnet
|
||||
torrent.torrentObject = torrentObject
|
||||
|
||||
torrent.on('ready', () => {
|
||||
console.log('start downloading', torrent.infoHash, 'to', torrent.path)
|
||||
send('downloading', torrent.infoHash)
|
||||
})
|
||||
|
||||
torrent.on('done', () => {
|
||||
console.log('download done', torrent.infoHash)
|
||||
send('downloadDone', torrent.infoHash)
|
||||
})
|
||||
|
||||
let now = Date.now()
|
||||
torrent.on('download', (bytes) => {
|
||||
if(Date.now() - now < 100)
|
||||
return
|
||||
now = Date.now()
|
||||
|
||||
const progress = (bytes) => {
|
||||
send('downloadProgress', torrent.infoHash, {
|
||||
received: bytes,
|
||||
downloaded: torrent.downloaded,
|
||||
@ -614,6 +599,27 @@ module.exports = async ({
|
||||
progress: torrent.progress,
|
||||
timeRemaining: torrent.timeRemaining
|
||||
})
|
||||
}
|
||||
|
||||
torrent.on('ready', () => {
|
||||
console.log('start downloading', torrent.infoHash, 'to', torrent.path)
|
||||
send('downloading', torrent.infoHash)
|
||||
})
|
||||
|
||||
torrent.on('done', () => {
|
||||
console.log('download done', torrent.infoHash)
|
||||
progress(0) // update progress
|
||||
send('downloadDone', torrent.infoHash)
|
||||
})
|
||||
|
||||
let now = Date.now()
|
||||
progress(0) // immediately display progress
|
||||
torrent.on('download', (bytes) => {
|
||||
if(Date.now() - now < 100)
|
||||
return
|
||||
now = Date.now()
|
||||
|
||||
progress(bytes)
|
||||
})
|
||||
|
||||
if(callback)
|
||||
|
Loading…
Reference in New Issue
Block a user