mirror of
https://github.com/zoriya/flood.git
synced 2025-12-21 06:35:14 +00:00
Properly start/stop torrents
This commit is contained in:
@@ -269,42 +269,64 @@ var client = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
stopTorrent: function(hash, callback) {
|
stopTorrent: function(hashes, callback) {
|
||||||
if (!util.isArray(hash)) {
|
if (!util.isArray(hashes)) {
|
||||||
hash = [hash];
|
hashes = [hashes];
|
||||||
} else {
|
} else {
|
||||||
hash = String(hash).split(',');
|
hashes = String(hashes).split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, len = hash.length; i < len; i++) {
|
var multicall = [
|
||||||
rTorrent.get('d.close', [hash[i]]).then(function(data) {
|
[]
|
||||||
|
];
|
||||||
|
|
||||||
|
hashes.forEach(function (hash) {
|
||||||
|
multicall[0].push({
|
||||||
|
methodName: 'd.stop',
|
||||||
|
params: [hash]
|
||||||
|
});
|
||||||
|
multicall[0].push({
|
||||||
|
methodName: 'd.close',
|
||||||
|
params: [hash]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
rTorrent.get('system.multicall', multicall)
|
||||||
|
.then(function(data) {
|
||||||
callback(null, data);
|
callback(null, data);
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
callback(error, null);
|
callback(error, null);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
startTorrent: function(hash, callback) {
|
startTorrent: function(hashes, callback) {
|
||||||
if (!util.isArray(hash)) {
|
if (!util.isArray(hashes)) {
|
||||||
hash = [hash];
|
hashes = [hashes];
|
||||||
} else {
|
} else {
|
||||||
hash = String(hash).split(',');
|
hashes = String(hashes).split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, len = hash.length; i < len; i++) {
|
var multicall = [
|
||||||
rTorrent.get('d.resume', [hash[i]]).then(function(data) {
|
[]
|
||||||
|
];
|
||||||
|
|
||||||
|
hashes.forEach(function (hash) {
|
||||||
|
multicall[0].push({
|
||||||
|
methodName: 'd.open',
|
||||||
|
params: [hash]
|
||||||
|
});
|
||||||
|
multicall[0].push({
|
||||||
|
methodName: 'd.start',
|
||||||
|
params: [hash]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
rTorrent.get('system.multicall', multicall)
|
||||||
|
.then(function(data) {
|
||||||
callback(null, data);
|
callback(null, data);
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
callback(error, null);
|
callback(error, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
rTorrent.get('d.start', [hash[i]]).then(function(data) {
|
|
||||||
callback(null, data);
|
|
||||||
}, function(error) {
|
|
||||||
callback(error, null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getTransferStats: function(callback) {
|
getTransferStats: function(callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user