feat(downloading): ability to choose files which you wanna download

This commit is contained in:
Alexey Kasyanchuk
2018-08-28 04:20:48 +03:00
parent 3326bc2505
commit 0b329b8328
3 changed files with 155 additions and 12 deletions

View File

@ -10,7 +10,8 @@ torrentClient.saveSession = (sessionFile) => {
torrent: torrent.torrentObject,
removeOnDone: torrent.removeOnDone,
paused: torrent.paused || torrent._paused
paused: torrent.paused || torrent._paused,
selection: torrent.files.map(file => typeof file.selected === 'undefined' || file.selected)
}))
}, null, 4), 'utf8');
}
@ -34,7 +35,7 @@ torrentClient.loadSession = (sessionFile) => {
return
}
const {torrents} = obj
torrents.forEach(({torrent, infoHash, path, removeOnDone, paused}) => {
torrents.forEach(({torrent, infoHash, path, removeOnDone, paused, selection}) => {
if(!torrent || !infoHash || !path)
{
logT('downloader', 'no info for starting download this torrent')
@ -51,6 +52,13 @@ torrentClient.loadSession = (sessionFile) => {
{
download._paused = true
}
if(selection)
{
download.on('metadata', () => {
logT('downloader', 'load torrent selection from session')
download.selectFiles(selection)
})
}
}
})
}