diff --git a/src/app/torrent-page.js b/src/app/torrent-page.js index 23f48d41..e29b7bfc 100644 --- a/src/app/torrent-page.js +++ b/src/app/torrent-page.js @@ -18,6 +18,7 @@ var moment = require('moment'); import RefreshIndicator from 'material-ui/RefreshIndicator'; let rating = require('./rating'); import LinearProgress from 'material-ui/LinearProgress'; +import FlatButton from 'material-ui/FlatButton'; import {fileTypeDetect} from './content' import {contentIcon} from './torrent' @@ -247,11 +248,14 @@ export default class TorrentPage extends Page { } window.torrentSocket.on('downloading', this.downloading); - this.downloadDone = (hash) => { + this.downloadDone = (hash, canceled) => { if(this.props.hash != hash) return; - this.setState({downloading: false}) + this.setState({ + downloading: false, + askDownloading: !canceled + }) } window.torrentSocket.on('downloadDone', this.downloadDone); @@ -402,6 +406,14 @@ export default class TorrentPage extends Page { mode="determinate" value={this.state.downloadProgress && this.state.downloadProgress.progress * 100} /> + { + window.torrentSocket.emit('downloadCancel', this.torrent.hash) + }} + label="Cancel download" + secondary={true} + icon={} + /> }
BTIH:
{this.torrent.hash}
diff --git a/src/background/spider.js b/src/background/spider.js index 90f709be..646baafd 100644 --- a/src/background/spider.js +++ b/src/background/spider.js @@ -584,11 +584,14 @@ setInterval(() => { recive('download', (magnet) => { console.log('download', magnet) - if(torrentClient.get(magnet)) + if(torrentClient.get(magnet)) { + console.log('aready added') return + } torrentClient.add(magnet, {path: config.client.downloadPath}, (torrent) =>{ torrentClientHashMap[torrent.infoHash] = magnet + console.log('start downloading', torrent.infoHash) send('downloading', torrent.infoHash) torrent.on('done', () => { @@ -622,7 +625,7 @@ setInterval(() => { return } - client.remove(id, (err) => { + torrentClient.remove(id, (err) => { if(err) { callback(false) @@ -630,6 +633,8 @@ setInterval(() => { } delete torrentClientHashMap[hash] + send('downloadDone', hash, true) + if(callback) callback(true) })