Merge pull request #612 from feross/error-on-duplicate
Error on duplicate add (fixes to PR #593)
This commit is contained in:
@@ -828,21 +828,18 @@ function torrentInfoHash (torrentKey, infoHash) {
|
|||||||
torrentSummary ? 'existing' : 'new', torrentKey)
|
torrentSummary ? 'existing' : 'new', torrentKey)
|
||||||
|
|
||||||
if (!torrentSummary) {
|
if (!torrentSummary) {
|
||||||
// Check if another torrent has the same infoHash
|
// Check if an existing (non-active) torrent has the same info hash
|
||||||
var duplicate = state.saved.torrents.find((x) => x.infoHash === infoHash)
|
if (state.saved.torrents.find((t) => t.infoHash === infoHash)) {
|
||||||
|
ipcRenderer.send('wt-stop-torrenting', infoHash)
|
||||||
if (duplicate) {
|
return onError(new Error('Cannot add duplicate torrent'))
|
||||||
duplicate.torrentKey = torrentKey
|
|
||||||
duplicate.status = 'new'
|
|
||||||
sound.play('ENABLE')
|
|
||||||
} else {
|
|
||||||
torrentSummary = {
|
|
||||||
torrentKey: torrentKey,
|
|
||||||
status: 'new'
|
|
||||||
}
|
|
||||||
state.saved.torrents.unshift(torrentSummary)
|
|
||||||
sound.play('ADD')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
torrentSummary = {
|
||||||
|
torrentKey: torrentKey,
|
||||||
|
status: 'new'
|
||||||
|
}
|
||||||
|
state.saved.torrents.unshift(torrentSummary)
|
||||||
|
sound.play('ADD')
|
||||||
}
|
}
|
||||||
|
|
||||||
torrentSummary.infoHash = infoHash
|
torrentSummary.infoHash = infoHash
|
||||||
|
|||||||
Reference in New Issue
Block a user