Obey 'Start Torrnt' option when adding by file

This commit is contained in:
John Furrow
2016-06-18 15:46:18 -07:00
parent 59bbeda615
commit 157ce15317
4 changed files with 18 additions and 6 deletions
@@ -26,7 +26,8 @@ export default class AddTorrentsByFile extends React.Component {
this.state = {
destination: SettingsStore.getFloodSettings('torrentDestination'),
isAddingTorrents: false,
files: null
files: null,
startTorrents: SettingsStore.getFloodSettings('startTorrentsOnLoad')
};
METHODS_TO_BIND.forEach((method) => {
@@ -116,6 +117,7 @@ export default class AddTorrentsByFile extends React.Component {
});
fileData.append('destination', this.state.destination);
fileData.append('start', this.state.startTorrents);
TorrentActions.addTorrentsByFiles(fileData, this.state.destination);
}
@@ -24,7 +24,7 @@ export default class AddTorrentsByURL extends React.Component {
destination: SettingsStore.getFloodSettings('torrentDestination'),
isAddingTorrents: false,
urlTextboxes: [{value: ''}],
startTorrents: true
startTorrents: SettingsStore.getFloodSettings('startTorrentsOnLoad')
};
METHODS_TO_BIND.forEach((method) => {
+12 -3
View File
@@ -105,19 +105,28 @@ class ClientRequest {
// rTorrent method calls.
addFilesMethodCall(options) {
let files = this.getEnsuredArray(options.files);
let path = options.path;
let start = options.start;
files.forEach((file) => {
let methodCall = 'load.raw_start';
let parameters = ['', file.buffer];
let timeAdded = Math.floor(Date.now() / 1000);
if (options.path && options.path !== '') {
parameters.push(`d.directory.set="${options.path}"`);
if (path && path !== '') {
parameters.push(`d.directory.set="${path}"`);
}
parameters.push(`d.custom.set=x-filename,${file.filename}`);
parameters.push(`d.custom.set=addtime,${timeAdded}`);
this.requests.push(this.getMethodCall('load.raw_start', parameters));
// The start value is a string because it was appended to a FormData
// object.
if (start === 'false') {
methodCall = 'load.raw';
}
this.requests.push(this.getMethodCall(methodCall, parameters));
});
}
+2 -1
View File
@@ -22,6 +22,7 @@ var client = {
let files = req.files;
let path = req.body.destination;
let request = new ClientRequest();
let start = req.body.start;
request.add('createDirectory', {path});
request.send();
@@ -31,7 +32,7 @@ var client = {
// torrent files reliably.
files.forEach((file, index) => {
let fileRequest = new ClientRequest();
fileRequest.add('addFiles', {files: file, path});
fileRequest.add('addFiles', {files: file, path, start});
// Set the callback for only the last request.
if (index === files.length - 1) {