Skip to content

Commit ac6b965

Browse files
authored
Merge branch 'master' into fix-deprecated-loader
2 parents eb2d1f1 + 454f771 commit ac6b965

File tree

8 files changed

+433
-33
lines changed

8 files changed

+433
-33
lines changed

.github/workflows/publish-rolling.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,12 @@ jobs:
125125

126126
steps:
127127
- uses: actions/checkout@v4
128-
- uses: pnpm/action-setup@v4
129128

130129
- name: Use Node.js ${{ matrix.node }}
131130
uses: actions/setup-node@v4
132131
with:
133132
node-version: ${{ matrix.node }}
134133
registry-url: 'https://registry.npmjs.org'
135-
cache: 'pnpm'
136134

137135
- name: Set up QEMU
138136
uses: docker/setup-qemu-action@v3

client/src/javascript/i18n/strings/he.json

Lines changed: 394 additions & 1 deletion
Large diffs are not rendered by default.

pnpm-lock.yaml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/services/qBittorrent/clientGatewayService.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ class QBittorrentClientGatewayService extends ClientGatewayService {
8585
throw new Error();
8686
}
8787

88+
const method = isApiVersionAtLeast(await this.clientRequestManager.apiVersion, '2.11.0') ? 'stopped' : 'paused';
8889
await this.clientRequestManager
8990
.torrentsAddFiles(fileBuffers, {
9091
savepath: destination,
9192
tags: tags.join(','),
92-
[isApiVersionAtLeast(this.clientRequestManager.apiVersion, '2.11.0') ? 'stopped' : 'paused']: !start,
93+
[method]: !start,
9394
root_folder: !isBasePath,
9495
contentLayout: isBasePath ? 'NoSubfolder' : undefined,
9596
sequentialDownload: isSequential,
@@ -119,11 +120,12 @@ class QBittorrentClientGatewayService extends ClientGatewayService {
119120
throw new Error();
120121
}
121122

123+
const method = isApiVersionAtLeast(await this.clientRequestManager.apiVersion, '2.11.0') ? 'stopped' : 'paused';
122124
await this.clientRequestManager
123125
.torrentsAddURLs(urls, {
124126
savepath: destination,
125127
tags: tags.join(','),
126-
[isApiVersionAtLeast(this.clientRequestManager.apiVersion, '2.11.0') ? 'stopped' : 'paused']: !start,
128+
[method]: !start,
127129
root_folder: !isBasePath,
128130
contentLayout: isBasePath ? 'NoSubfolder' : undefined,
129131
sequentialDownload: isSequential,
@@ -526,7 +528,7 @@ class QBittorrentClientGatewayService extends ClientGatewayService {
526528

527529
async testGateway(): Promise<void> {
528530
return this.clientRequestManager
529-
.updateAuthCookie()
531+
.updateConnection()
530532
.then(() => this.processClientRequestSuccess(undefined), this.processClientRequestError);
531533
}
532534
}

server/services/qBittorrent/clientRequestManager.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const EMPTY_SERVER_STATE = {
3636
class ClientRequestManager {
3737
private connectionSettings: QBittorrentConnectionSettings;
3838
private apiBase: string;
39-
apiVersion: string | null = null;
39+
apiVersion: Promise<string | undefined> = Promise.resolve(undefined);
4040
private authCookie: Promise<string | undefined> = Promise.resolve(undefined);
4141
private isMainDataPending = false;
4242

@@ -80,17 +80,27 @@ class ClientRequestManager {
8080
});
8181
}
8282

83-
async updateAuthCookie(connectionSettings?: QBittorrentConnectionSettings): Promise<void> {
84-
let authFailed = false;
83+
async updateConnection(connectionSettings?: QBittorrentConnectionSettings): Promise<void> {
84+
let failed = false;
8585

8686
this.authCookie = this.authenticate(connectionSettings).catch(() => {
87-
authFailed = true;
87+
failed = true;
8888
return undefined;
8989
});
9090

91+
this.apiVersion = this.authCookie
92+
.then(() => {
93+
return !failed ? this.getApiVersion() : Promise.resolve(undefined);
94+
})
95+
.catch(() => {
96+
failed = true;
97+
return undefined;
98+
});
99+
91100
await this.authCookie;
101+
await this.apiVersion;
92102

93-
if (authFailed) {
103+
if (failed) {
94104
throw new Error();
95105
}
96106
}
@@ -120,15 +130,12 @@ class ClientRequestManager {
120130
});
121131
}
122132

123-
async getApiVersion(): Promise<void> {
124-
try {
125-
const {data} = await axios.get(`${this.apiBase}/app/webapiVersion`, {
133+
async getApiVersion(): Promise<string> {
134+
return axios
135+
.get<string>(`${this.apiBase}/app/webapiVersion`, {
126136
headers: await this.getRequestHeaders(),
127-
});
128-
this.apiVersion = data;
129-
} catch (error) {
130-
this.apiVersion = null;
131-
}
137+
})
138+
.then((res) => res.data);
132139
}
133140

134141
async getTorrentInfos(): Promise<QBittorrentTorrentInfos> {
@@ -306,7 +313,7 @@ class ClientRequestManager {
306313
}
307314

308315
async torrentsPause(hashes: Array<string>): Promise<void> {
309-
const method = isApiVersionAtLeast(this.apiVersion, '2.11.0') ? 'stop' : 'pause';
316+
const method = isApiVersionAtLeast(await this.apiVersion, '2.11.0') ? 'stop' : 'pause';
310317
return axios
311318
.post(
312319
`${this.apiBase}/torrents/${method}`,
@@ -323,7 +330,7 @@ class ClientRequestManager {
323330
}
324331

325332
async torrentsResume(hashes: Array<string>): Promise<void> {
326-
const method = isApiVersionAtLeast(this.apiVersion, '2.11.0') ? 'start' : 'resume';
333+
const method = isApiVersionAtLeast(await this.apiVersion, '2.11.0') ? 'start' : 'resume';
327334
return axios
328335
.post(
329336
`${this.apiBase}/torrents/${method}`,
@@ -622,8 +629,7 @@ class ClientRequestManager {
622629
constructor(connectionSettings: QBittorrentConnectionSettings) {
623630
this.connectionSettings = connectionSettings;
624631
this.apiBase = `${connectionSettings.url}/api/v2`;
625-
this.updateAuthCookie().catch(() => undefined);
626-
this.getApiVersion();
632+
this.updateConnection().catch(() => undefined);
627633
}
628634
}
629635

server/services/qBittorrent/util/apiVersionCheck.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function isApiVersionAtLeast(currentVersion: string | null, targetVersion: string): boolean {
1+
export function isApiVersionAtLeast(currentVersion: string | undefined, targetVersion: string): boolean {
22
if (!currentVersion) {
33
return false;
44
}

server/services/rTorrent/util/XMLRPCDeserializer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const closeTag = (elementName: string) => {
5555
break;
5656
case 'i4':
5757
case 'i8':
58+
case 'int':
5859
case 'string':
5960
case 'name':
6061
dataStack.push(tagValue);

server/services/rTorrent/util/XMLRPCSerializer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const value = (value: XMLRPCValue): string => {
4646
};
4747

4848
const data = (values: XMLRPCValue[]) => {
49-
return `<data>${values.map(value)}</data>`;
49+
return `<data>${values.map(value).join('')}</data>`;
5050
};
5151

5252
const member = ([key, val]: [string, XMLRPCValue]) => {
@@ -64,7 +64,7 @@ const param = (param: XMLRPCValue) => {
6464
const sParams = (params: XMLRPCValue[]) => {
6565
if (!params?.length) return '';
6666

67-
return `<params>${params.map(param)}</params>`;
67+
return `<params>${params.map(param).join('')}</params>`;
6868
};
6969

7070
const serializeSync = (methodName: string, params: XMLRPCValue[]): string => {

0 commit comments

Comments
 (0)