Skip to content

Commit

Permalink
findOnOtherSites only completes if the torrent is complete (cross-see…
Browse files Browse the repository at this point in the history
…d#523)

This changes the logic of `findOnOtherSites` to ensure that the search
is considered as "complete" only when the torrent itself is complete.

This avoids issues where the torrent is not complete yet the search is
marked as successful therefore there won't be a search done for the
torrent once it has completed.
  • Loading branch information
ColinHebert authored Nov 3, 2023
1 parent 3a7e385 commit 7ba06fa
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ async function findOnOtherSites(
}
);

const matches = assessed.filter(
(e) =>
e.assessment.decision === Decision.MATCH ||
e.assessment.decision === Decision.MATCH_SIZE_ONLY
);
const actionResults = await performActions(searchee, matches);
if (actionResults.includes(InjectionResult.TORRENT_NOT_COMPLETE)) {
// If the torrent is not complete, "cancel the search"
return { matches: 0, searchedIndexers: 0 };
}

await updateSearchTimestamps(searchee.name, Array.from(notRateLimited));

await updateIndexerStatus(
Expand All @@ -121,21 +132,13 @@ async function findOnOtherSites(
Array.from(rateLimited)
);

const matches = assessed.filter(
(e) =>
e.assessment.decision === Decision.MATCH ||
e.assessment.decision === Decision.MATCH_SIZE_ONLY
const zipped: [ResultAssessment, string, ActionResult][] = zip(
matches.map((m) => m.assessment),
matches.map((m) => m.tracker),
actionResults
);
const actionResults = await performActions(searchee, matches);
sendResultsNotification(searchee, zipped, Label.SEARCH);

if (!actionResults.includes(InjectionResult.TORRENT_NOT_COMPLETE)) {
const zipped: [ResultAssessment, string, ActionResult][] = zip(
matches.map((m) => m.assessment),
matches.map((m) => m.tracker),
actionResults
);
sendResultsNotification(searchee, zipped, Label.SEARCH);
}
return { matches: matches.length, searchedIndexers: response.length };
}

Expand Down

0 comments on commit 7ba06fa

Please sign in to comment.