fix(qbittorrent): handle v5 stopped torrent states for pause functionality (#6211)
This commit is contained in:
1 parent
af89423f66
commit
2ada1aa249
4 files changed
+35
-9
No files matched your search
@@ -20,11 +20,23 @@ export const createIntegrationRequestHandler = <
|
||||
TInput extends Record<string, unknown>,
|
||||
>(
|
||||
options: Options<TData, TKind, TInput>,
|
||||
) => ({
|
||||
handler: (integration: IntegrationOfKind<TKind>, itemOptions: TInput) => {
|
||||
const inner = createRequestHandler<TData, { integrationId: string; options: TInput }>({
|
||||
requestAsync: async (input) => options.requestAsync(integration, input.options),
|
||||
});
|
||||
return inner.handler({ integrationId: integration.id, options: itemOptions });
|
||||
},
|
||||
});
|
||||
) => {
|
||||
const integrationMap = new Map<string, IntegrationOfKind<TKind>>();
|
||||
const inner = createRequestHandler<TData, { integrationId: string; options: TInput }>({
|
||||
requestAsync: async (input) => {
|
||||
const integration = integrationMap.get(input.integrationId);
|
||||
if (!integration) {
|
||||
throw new Error(`Integration ${input.integrationId} not found in cache`);
|
||||
}
|
||||
return options.requestAsync(integration, input.options);
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
invalidateCache: inner.invalidateCache,
|
||||
handler: (integration: IntegrationOfKind<TKind>, itemOptions: TInput) => {
|
||||
integrationMap.set(integration.id, integration);
|
||||
return inner.handler({ integrationId: integration.id, options: itemOptions });
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -22,6 +22,10 @@ export const createRequestHandler = <TData, TInput extends Record<string, unknow
|
||||
const inflight = new Map<string, Promise<CacheEntry<TData>>>();
|
||||
|
||||
return {
|
||||
invalidateCache: () => {
|
||||
cache.clear();
|
||||
inflight.clear();
|
||||
},
|
||||
handler: (input: TInput) => ({
|
||||
async getDataAsync(): Promise<{ data: TData; timestamp: Date }> {
|
||||
const ttl = options.cacheTtlMs ?? DEFAULT_TTL_MS;
|
||||
|
||||
Reference in new issue
Block a user