Record changed port while re-announcing (#1102)

This commit is contained in:
Cønstantine Kovalensky 2023-11-15 14:16:03 +04:00 committed by GitHub
commit b3b659a5c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View file

@ -42,6 +42,9 @@ foreach ($info_hash_array[1] as $hash) {
$decoded_hash = urldecode($hash);
if (strlen($decoded_hash) !== 20) {
continue;
}
if ($scrape_cache = CACHE('tr_cache')->get(SCRAPE_LIST_PREFIX . bin2hex($decoded_hash))) {
$torrents['files'][$info_key = array_key_first($scrape_cache)] = $scrape_cache[$info_key];
} else {
@ -79,7 +82,7 @@ if (!empty($info_hash_count)) {
foreach ($scrapes as $scrape) {
$hash_v1 = !empty($scrape['info_hash']) ? $scrape['info_hash'] : '';
$hash_v2 = !empty($scrape['info_hash_v2']) ? substr($scrape['info_hash_v2'], 0, 20) : '';
$info_hash_scrape = (in_array(urlencode($hash_v2), $info_hash_array[1])) ? $hash_v2 : $hash_v1;
$info_hash_scrape = (in_array(urlencode($hash_v1), $info_hash_array[1])) ? $hash_v1 : $hash_v2; // Replace logic to prioritize $hash_v2, in case of future prioritization of v2
$torrents['files'][$info_hash_scrape] = [
'complete' => (int)$scrape['seeders'],