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>
|
</div>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.state.downloading
|
(this.state.downloading || this.state.downloaded)
|
||||||
&&
|
&&
|
||||||
<div className='row w100p inline text-nowrap' style={{maxWidth: 580}}>
|
<div className='row w100p inline text-nowrap' style={{maxWidth: 580}}>
|
||||||
<div style={{marginRight: 5, color: 'rgb(0, 188, 212)'}}>{__('downloading')}: </div>
|
<div style={{marginRight: 5, color: 'rgb(0, 188, 212)'}}>{__('downloading')}: </div>
|
||||||
|
@ -591,22 +591,7 @@ module.exports = async ({
|
|||||||
torrentClientHashMap[torrent.infoHash] = magnet
|
torrentClientHashMap[torrent.infoHash] = magnet
|
||||||
torrent.torrentObject = torrentObject
|
torrent.torrentObject = torrentObject
|
||||||
|
|
||||||
torrent.on('ready', () => {
|
const progress = (bytes) => {
|
||||||
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()
|
|
||||||
|
|
||||||
send('downloadProgress', torrent.infoHash, {
|
send('downloadProgress', torrent.infoHash, {
|
||||||
received: bytes,
|
received: bytes,
|
||||||
downloaded: torrent.downloaded,
|
downloaded: torrent.downloaded,
|
||||||
@ -614,6 +599,27 @@ module.exports = async ({
|
|||||||
progress: torrent.progress,
|
progress: torrent.progress,
|
||||||
timeRemaining: torrent.timeRemaining
|
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)
|
if(callback)
|
||||||
|
Loading…
Reference in New Issue
Block a user