server: rTorrent: remove "hasLoadThrow" and fold into "isJSONCapable"

It appears that the "hasLoadThrow" check has some weird issues. As
pretty much all JSON capable versions have "load.throw", and the
JSON request requires base64 encoding, fold the check into "isJSONCapable".

Bug: #557
This commit is contained in:
Jesse Chan
2022-05-14 16:32:09 -07:00
parent a1c2f1d238
commit 503f80b098

View File

@@ -79,8 +79,6 @@ class RTorrentClientGatewayService extends ClientGatewayService {
isInitialSeeding, isInitialSeeding,
start, start,
}: Required<AddTorrentByFileOptions>): Promise<string[]> { }: Required<AddTorrentByFileOptions>): Promise<string[]> {
const {hasLoadThrow} = await this.availableMethodCalls;
await fs.promises.mkdir(destination, {recursive: true}); await fs.promises.mkdir(destination, {recursive: true});
let processedFiles: string[] = files; let processedFiles: string[] = files;
@@ -108,7 +106,7 @@ class RTorrentClientGatewayService extends ClientGatewayService {
const result: string[] = []; const result: string[] = [];
if (hasLoadThrow && this.clientRequestManager.isJSONCapable) { if (this.clientRequestManager.isJSONCapable) {
await this.clientRequestManager await this.clientRequestManager
.methodCall('system.multicall', [ .methodCall('system.multicall', [
await Promise.all( await Promise.all(
@@ -155,8 +153,6 @@ class RTorrentClientGatewayService extends ClientGatewayService {
isInitialSeeding, isInitialSeeding,
start, start,
}: Required<AddTorrentByURLOptions>): Promise<string[]> { }: Required<AddTorrentByURLOptions>): Promise<string[]> {
const {hasLoadThrow} = await this.availableMethodCalls;
await fs.promises.mkdir(destination, {recursive: true}); await fs.promises.mkdir(destination, {recursive: true});
const {files, urls} = await fetchUrls(inputUrls, cookies); const {files, urls} = await fetchUrls(inputUrls, cookies);
@@ -169,7 +165,7 @@ class RTorrentClientGatewayService extends ClientGatewayService {
if (urls[0]) { if (urls[0]) {
let methodName: string; let methodName: string;
if (hasLoadThrow) { if (this.clientRequestManager.isJSONCapable) {
methodName = start ? 'load.start_throw' : 'load.throw'; methodName = start ? 'load.start_throw' : 'load.throw';
} else { } else {
methodName = start ? 'load.start' : 'load.normal'; methodName = start ? 'load.start' : 'load.normal';
@@ -801,7 +797,6 @@ class RTorrentClientGatewayService extends ClientGatewayService {
} }
async fetchAvailableMethodCalls(fallback = false): Promise<{ async fetchAvailableMethodCalls(fallback = false): Promise<{
hasLoadThrow: boolean;
clientSetting: string[]; clientSetting: string[];
torrentContent: string[]; torrentContent: string[];
torrentList: string[]; torrentList: string[];
@@ -841,7 +836,6 @@ class RTorrentClientGatewayService extends ClientGatewayService {
: (methodCalls: Array<string>) => methodCalls; : (methodCalls: Array<string>) => methodCalls;
return { return {
hasLoadThrow: methodList?.includes('load.throw') ?? false,
clientSetting: getAvailableMethodCalls(getMethodCalls(clientSettingMethodCallConfigs)), clientSetting: getAvailableMethodCalls(getMethodCalls(clientSettingMethodCallConfigs)),
torrentContent: getAvailableMethodCalls(getMethodCalls(torrentContentMethodCallConfigs)), torrentContent: getAvailableMethodCalls(getMethodCalls(torrentContentMethodCallConfigs)),
torrentList: getAvailableMethodCalls(getMethodCalls(torrentListMethodCallConfigs)), torrentList: getAvailableMethodCalls(getMethodCalls(torrentListMethodCallConfigs)),