Fix linting errors

pull/141/head
Jason Fischer 2 years ago
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 rateUl = 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;
rateUl += torrent.rateUpload;
if (torrent.percentDone === 1) {
completed++;
completed += 1;
}
}

@ -1,6 +1,5 @@
import { httpProxy } from "utils/http";
import { formatApiCall } from "utils/api-helpers";
import getServiceWidget from "utils/service-helpers";
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 method = "POST";
const auth = `${widget.username}:${widget.password}`;
const body = JSON.stringify({
method: "torrent-get",
arguments: {
@ -27,27 +27,27 @@ export default async function transmissionProxyHandler(req, res) {
}
});
const reqHeaders = {
const headers = {
"content-type": "application/json",
};
let [status, contentType, data, responseHeaders] = await httpProxy(url, {
method: method,
auth: `${widget.username}:${widget.password}`,
body: body,
headers: reqHeaders,
method,
auth,
body,
headers,
});
if (status === 409) {
// 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
[status, contentType, data] = await httpProxy(url, {
method: method,
auth: `${widget.username}:${widget.password}`,
body: body,
headers: reqHeaders,
[status, contentType, data, responseHeaders] = await httpProxy(url, {
method,
auth,
body,
headers,
});
}

Loading…
Cancel
Save