Skip to content

Commit

Permalink
Add searchLimit to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricionaweb committed Jun 5, 2023
1 parent f7c6dc6 commit 0b16355
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ function createCommandWithSharedOptions(name, description) {
"--search-timeout <timeout>",
"Timeout for unresponsive searches",
fallback(fileConfig.searchTimeout, "30 seconds")
)
.option(
"--search-limit <number>",
"The number of searches before stops",
parseFloat,
fallback(fileConfig.searchLimit, 0)
);
}

Expand Down Expand Up @@ -334,12 +340,6 @@ createCommandWithSharedOptions("search", "Search for cross-seeds")
"torrent files separated by spaces"
).hideHelp()
)
.addOption(
new Option(
"--search-limit <number>",
"set the limit of searches for the running"
)
)
.action(async (options) => {
try {
const runtimeConfig = processOptions(options);
Expand Down
7 changes: 7 additions & 0 deletions src/config.template.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,11 @@ module.exports = {
* null
*/
searchTimeout: undefined,

/**
* The number of searches to be done before it stop.
* Combine this with "excludeRecentSearch" and "searchCadence" for better results.
* Default is no limit.
*/
searchLimit: undefined,
};
7 changes: 7 additions & 0 deletions src/config.template.docker.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,11 @@ module.exports = {
* null
*/
searchTimeout: undefined,

/**
* The number of searches to be done before stop.
* Combine this with "excludeRecentSearch" and "searchCadence" for better results.
* Default is no limit.
*/
searchLimit: undefined,
};
1 change: 1 addition & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface FileConfig {
rssCadence?: string;
snatchTimeout?: string;
searchTimeout?: string;
searchLimit?: number;
}

interface GenerateConfigParams {
Expand Down
16 changes: 8 additions & 8 deletions src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ async function findSearchableTorrents() {
message: `Found ${allSearchees.length} torrents, ${filteredTorrents.length} suitable to search for matches`,
});

if (searchLimit && filteredTorrents.length > searchLimit) {
logger.info({
label: Label.SEARCH,
message: `Limited to ${searchLimit} searches`,
});

filteredTorrents = filteredTorrents.slice(0, searchLimit);
}
if (searchLimit && filteredTorrents.length > searchLimit) {
logger.info({
label: Label.SEARCH,
message: `Limited to ${searchLimit} searches`,
});

filteredTorrents = filteredTorrents.slice(0, searchLimit);
}

return { samples: filteredTorrents, hashesToExclude };
}
Expand Down

0 comments on commit 0b16355

Please sign in to comment.