From f72d5a0f5654706a27574a75c13522c711bef44b Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Fri, 22 Apr 2022 13:23:54 +0800 Subject: [PATCH] tracker always update torrent --- app/Repositories/TrackerRepository.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/Repositories/TrackerRepository.php b/app/Repositories/TrackerRepository.php index aa75e864..d9da5e3d 100644 --- a/app/Repositories/TrackerRepository.php +++ b/app/Repositories/TrackerRepository.php @@ -766,23 +766,19 @@ class TrackerRepository extends BaseRepository */ private function updateTorrent(Torrent $torrent, $queries, bool $isPeerExists) { - if (empty($queries['event'])) { - do_log("no event, return", 'debug'); - return; + if (!empty($queries['event'])) { + $torrent->seeders = Peer::query() + ->where('torrent', $torrent->id) + ->where('to_go', '=',0) + ->count(); + + $torrent->leechers = Peer::query() + ->where('torrent', $torrent->id) + ->where('to_go', '>', 0) + ->count(); } - $torrent->seeders = Peer::query() - ->where('torrent', $torrent->id) - ->where('to_go', '=',0) - ->count(); - - $torrent->leechers = Peer::query() - ->where('torrent', $torrent->id) - ->where('to_go', '>', 0) - ->count(); - $torrent->visible = Torrent::VISIBLE_YES; $torrent->last_action = Carbon::now(); - if ($isPeerExists && $queries['event'] == 'completed') { $torrent->times_completed = DB::raw("times_completed + 1"); }