Skip to content

Commit

Permalink
Remove withTempConfigOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmgoodnow committed Jan 18, 2021
1 parent e671b46 commit 7c39e47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
11 changes: 2 additions & 9 deletions src/runtimeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,5 @@ function getRuntimeConfig() {
return runtimeConfig;
}

async function withTempConfigOptions(tempOptions, func) {
const ogRuntimeConfig = runtimeConfig;
setRuntimeConfig({ ...ogRuntimeConfig, ...tempOptions });
const ret = await func();
setRuntimeConfig(ogRuntimeConfig);
return ret;
}

module.exports = { getRuntimeConfig, setRuntimeConfig, withTempConfigOptions };
exports.setRuntimeConfig = setRuntimeConfig;
exports.getRuntimeConfig = getRuntimeConfig;
7 changes: 2 additions & 5 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { searchForSingleTorrentByName } = require("./index");
const { validateJackettApi } = require("./jackett");
const logger = require("./logger");
const { DAEMON_MODE_URL_HASH, README_URL } = require("./constants");
const { withTempConfigOptions } = require("./runtimeConfig");
const { getRuntimeConfig } = require("./runtimeConfig");

function getData(req) {
Expand Down Expand Up @@ -50,14 +49,12 @@ async function handleRequest(req, res) {
return;
}
const dataStr = await getData(req);
const { name, ...options } = parseData(dataStr);
const { name } = parseData(dataStr);
res.writeHead(204);
res.end();
logger.log("Received name", name);
try {
const numFound = await withTempConfigOptions(options, () =>
searchForSingleTorrentByName(name)
);
const numFound = await searchForSingleTorrentByName(name);
if (numFound === null) {
logger.log(`Did not search for ${name}`);
} else {
Expand Down

0 comments on commit 7c39e47

Please sign in to comment.