mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 07:55:52 +01:00
🚑 Hotfix how the result from the services are awaited
This commit is contained in:
@@ -3,12 +3,11 @@ import { QBittorrent } from '@ctrl/qbittorrent';
|
|||||||
import { NormalizedTorrent } from '@ctrl/shared-torrent';
|
import { NormalizedTorrent } from '@ctrl/shared-torrent';
|
||||||
import { Transmission } from '@ctrl/transmission';
|
import { Transmission } from '@ctrl/transmission';
|
||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import { useConfig } from '../../../tools/state';
|
|
||||||
import { Config } from '../../../tools/types';
|
import { Config } from '../../../tools/types';
|
||||||
|
|
||||||
async function Post(req: NextApiRequest, res: NextApiResponse) {
|
async function Post(req: NextApiRequest, res: NextApiResponse) {
|
||||||
// Get the type of service from the request url
|
// Get the type of service from the request url
|
||||||
const { config }: { config: Config } = useConfig();
|
const { config }: { config: Config } = req.body;
|
||||||
const qBittorrentServices = config.services.filter((service) => service.type === 'qBittorrent');
|
const qBittorrentServices = config.services.filter((service) => service.type === 'qBittorrent');
|
||||||
const delugeServices = config.services.filter((service) => service.type === 'Deluge');
|
const delugeServices = config.services.filter((service) => service.type === 'Deluge');
|
||||||
const transmissionServices = config.services.filter((service) => service.type === 'Transmission');
|
const transmissionServices = config.services.filter((service) => service.type === 'Transmission');
|
||||||
@@ -21,45 +20,39 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
message: 'Missing services',
|
message: 'Missing services',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (qBittorrentServices) {
|
await Promise.all(
|
||||||
qBittorrentServices.map(async (service) =>
|
qBittorrentServices.map((service) =>
|
||||||
torrents.push(
|
new QBittorrent({
|
||||||
...(
|
|
||||||
await new QBittorrent({
|
|
||||||
baseUrl: service.url,
|
baseUrl: service.url,
|
||||||
username: service.username,
|
username: service.username,
|
||||||
password: service.password,
|
password: service.password,
|
||||||
}).getAllData()
|
})
|
||||||
).torrents
|
.getAllData()
|
||||||
|
.then((e) => e.torrents.map((torrent) => torrents.push(torrent)))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
await Promise.all(
|
||||||
if (delugeServices) {
|
delugeServices.map((service) =>
|
||||||
delugeServices.map(async (service) =>
|
new Deluge({
|
||||||
torrents.push(
|
|
||||||
...(
|
|
||||||
await new Deluge({
|
|
||||||
baseUrl: service.url,
|
baseUrl: service.url,
|
||||||
password: 'password' in service ? service.password : '',
|
password: service.password,
|
||||||
}).getAllData()
|
})
|
||||||
).torrents
|
.getAllData()
|
||||||
|
.then((e) => e.torrents.map((torrent) => torrents.push(torrent)))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
if (transmissionServices) {
|
|
||||||
// Map transmissionServices
|
// Map transmissionServices
|
||||||
transmissionServices.map(async (service) => {
|
await Promise.all(
|
||||||
torrents.push(
|
transmissionServices.map((service) =>
|
||||||
...(
|
new Transmission({
|
||||||
await new Transmission({
|
|
||||||
baseUrl: service.url,
|
baseUrl: service.url,
|
||||||
username: 'username' in service ? service.username : '',
|
username: service.username,
|
||||||
password: 'password' in service ? service.password : '',
|
password: service.password,
|
||||||
}).getAllData()
|
})
|
||||||
).torrents
|
.getAllData()
|
||||||
|
.then((e) => e.torrents.map((torrent) => torrents.push(torrent)))
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
res.status(200).json(torrents);
|
res.status(200).json(torrents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user