mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Fix linting errors
This commit is contained in:
parent
95b6ea0e23
commit
b19b4f047e
@ -28,16 +28,17 @@ export default function Transmission({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const torrents = torrentData.arguments.torrents;
|
const { torrents } = torrentData.arguments;
|
||||||
let rateDl = 0;
|
let rateDl = 0;
|
||||||
let rateUl = 0;
|
let rateUl = 0;
|
||||||
let completed = 0;
|
let completed = 0;
|
||||||
|
|
||||||
for (let torrent of torrents) {
|
for (let i = 0; i < torrents.length; i += 1) {
|
||||||
|
const torrent = torrents[i];
|
||||||
rateDl += torrent.rateDownload;
|
rateDl += torrent.rateDownload;
|
||||||
rateUl += torrent.rateUpload;
|
rateUl += torrent.rateUpload;
|
||||||
if (torrent.percentDone === 1) {
|
if (torrent.percentDone === 1) {
|
||||||
completed++;
|
completed += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { httpProxy } from "utils/http";
|
import { httpProxy } from "utils/http";
|
||||||
import { formatApiCall } from "utils/api-helpers";
|
import { formatApiCall } from "utils/api-helpers";
|
||||||
|
|
||||||
import getServiceWidget from "utils/service-helpers";
|
import getServiceWidget from "utils/service-helpers";
|
||||||
|
|
||||||
export default async function transmissionProxyHandler(req, res) {
|
export default async function transmissionProxyHandler(req, res) {
|
||||||
@ -20,6 +19,7 @@ export default async function transmissionProxyHandler(req, res) {
|
|||||||
const csrfHeaderName = "x-transmission-session-id";
|
const csrfHeaderName = "x-transmission-session-id";
|
||||||
|
|
||||||
const method = "POST";
|
const method = "POST";
|
||||||
|
const auth = `${widget.username}:${widget.password}`;
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
method: "torrent-get",
|
method: "torrent-get",
|
||||||
arguments: {
|
arguments: {
|
||||||
@ -27,27 +27,27 @@ export default async function transmissionProxyHandler(req, res) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const reqHeaders = {
|
const headers = {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
};
|
};
|
||||||
|
|
||||||
let [status, contentType, data, responseHeaders] = await httpProxy(url, {
|
let [status, contentType, data, responseHeaders] = await httpProxy(url, {
|
||||||
method: method,
|
method,
|
||||||
auth: `${widget.username}:${widget.password}`,
|
auth,
|
||||||
body: body,
|
body,
|
||||||
headers: reqHeaders,
|
headers,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status === 409) {
|
if (status === 409) {
|
||||||
// Transmission is rejecting the request, but returning a CSRF token
|
// Transmission is rejecting the request, but returning a CSRF token
|
||||||
reqHeaders[csrfHeaderName] = responseHeaders[csrfHeaderName];
|
headers[csrfHeaderName] = responseHeaders[csrfHeaderName];
|
||||||
|
|
||||||
// retry the request, now with the CSRF token
|
// retry the request, now with the CSRF token
|
||||||
[status, contentType, data] = await httpProxy(url, {
|
[status, contentType, data, responseHeaders] = await httpProxy(url, {
|
||||||
method: method,
|
method,
|
||||||
auth: `${widget.username}:${widget.password}`,
|
auth,
|
||||||
body: body,
|
body,
|
||||||
headers: reqHeaders,
|
headers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user