feat(downloading): save download session support

This commit is contained in:
Alexey Kasyanchuk
2018-06-27 04:47:22 +03:00
parent 27b46d15cc
commit 0d81364ca8
3 changed files with 56 additions and 5 deletions

View File

@ -576,7 +576,7 @@ module.exports = async ({
callback(true)
});
recive('download', (torrentObject) =>
torrentClient._add = (torrentObject, savePath) =>
{
const magnet = `magnet:?xt=urn:btih:${torrentObject.hash}`
console.log('download', magnet)
@ -585,12 +585,12 @@ module.exports = async ({
return
}
const torrent = torrentClient.add(magnet, {path: config.client.downloadPath})
const torrent = torrentClient.add(magnet, {path: savePath || config.client.downloadPath})
torrentClientHashMap[torrent.infoHash] = magnet
torrent.torrentObject = torrentObject
torrent.on('ready', () => {
console.log('start downloading', torrent.infoHash)
console.log('start downloading', torrent.infoHash, 'to', torrent.path)
send('downloading', torrent.infoHash)
})
@ -614,7 +614,9 @@ module.exports = async ({
timeRemaining: torrent.timeRemaining
})
})
});
}
recive('download', torrentClient._add);
recive('downloadCancel', (hash, callback) =>
{