Skip to content

Commit

Permalink
announce update torrent seeders/leechers revert to only increment/dec…
Browse files Browse the repository at this point in the history
…rement
  • Loading branch information
xiaomlove committed Nov 4, 2024
1 parent 70dab3e commit 2267169
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions public/announce.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
sql_query("DELETE FROM peers WHERE id = {$self['id']}") or err("D Err");
if (mysql_affected_rows() && !empty($snatchInfo))
{
// $updateset[] = ($self["seeder"] == "yes" ? "seeders = seeders - 1" : "leechers = leechers - 1");
$updateset[] = ($self["seeder"] == "yes" ? "seeders = seeders - 1" : "leechers = leechers - 1");
$hasChangeSeederLeecher = true;
sql_query("UPDATE snatched SET uploaded = uploaded + $trueupthis, downloaded = downloaded + $truedownthis, to_go = $left, $announcetime, last_action = ".$dt." WHERE id = {$snatchInfo['id']}") or err("SL Err 1");
}
Expand All @@ -544,7 +544,7 @@
if (mysql_affected_rows())
{
if ($seeder <> $self["seeder"]) {
// $updateset[] = ($seeder == "yes" ? "seeders = seeders + 1, leechers = leechers - 1" : "seeders = seeders - 1, leechers = leechers + 1");
$updateset[] = ($seeder == "yes" ? "seeders = seeders + 1, leechers = leechers - 1" : "seeders = seeders - 1, leechers = leechers + 1");
$hasChangeSeederLeecher = true;
}
if (!empty($snatchInfo)) {
Expand All @@ -566,7 +566,7 @@
sql_query($insertPeerSql) or err("PL Err 2");
if (mysql_affected_rows())
{
// $updateset[] = ($seeder == "yes" ? "seeders = seeders + 1" : "leechers = leechers + 1");
$updateset[] = ($seeder == "yes" ? "seeders = seeders + 1" : "leechers = leechers + 1");
$hasChangeSeederLeecher = true;
// $check = @mysql_fetch_row(@sql_query("SELECT COUNT(*) FROM snatched WHERE torrentid = $torrentid AND userid = $userid"));
$checkSnatchedRes = mysql_fetch_assoc(sql_query("SELECT id FROM snatched WHERE torrentid = $torrentid AND userid = $userid limit 1"));
Expand Down Expand Up @@ -626,11 +626,11 @@
do_log("$hrLog, not match", "debug");
}
}

if (isset($event) && !empty($event)) {
$updateset[] = 'seeders = ' . get_row_count("peers", "where torrent = $torrentid and to_go = 0");
$updateset[] = 'leechers = ' . get_row_count("peers", "where torrent = $torrentid and to_go > 0");
}
// revert to only increment/decrement
//if (isset($event) && !empty($event)) {
// $updateset[] = 'seeders = ' . get_row_count("peers", "where torrent = $torrentid and to_go = 0");
// $updateset[] = 'leechers = ' . get_row_count("peers", "where torrent = $torrentid and to_go > 0");
//}

if (count($updateset) || $hasChangeSeederLeecher) // Update only when there is change in peer counts
{
Expand Down

0 comments on commit 2267169

Please sign in to comment.