mirror of
https://github.com/zoriya/flood.git
synced 2026-06-09 13:01:54 +00:00
Obey 'Start Torrnt' option when adding by file
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user