Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
  #1  
Old 30th March 2021, 21:37
xblade's Avatar
xblade xblade is offline
Cod3r
 
Join Date: Nov 2020
P2P
Posts: 239
Thumbs up Cleanup
ive just updated to Debian 9 everything works ok but the clean up of torrent seeders ...seeds are there till it runs the clean up loose the seeds on seedbox and home pc..into 2 min after clean torrents are back any help would be nice


Code:
    $torrents = array();
    $res = sql_query("SELECT torrent, seeder, COUNT(*) AS c FROM peers GROUP BY torrent, seeder");
    while ($row = mysqli_fetch_assoc($res)) {
        if ($row["seeder"] == "yes")
            $key = "seeders";
        else
            $key = "leechers";
        $torrents[$row["torrent"]][$key] = $row["c"];
    }

    $res = sql_query("SELECT torrent, COUNT(*) AS c FROM comments GROUP BY torrent");
    while ($row = mysqli_fetch_assoc($res)) {
        $torrents[$row["torrent"]]["comments"] = $row["c"];
    }

    $fields = explode(":", "comments:leechers:seeders");
    $res = sql_query("SELECT id, seeders, leechers, comments FROM torrents");
    while ($row = mysqli_fetch_assoc($res)) {
        $id = $row["id"];
        $torr = $torrents[$id];
        foreach ($fields as $field) {
            if (!isset($torr[$field]))
                $torr[$field] = 0;
        }
        $update = array();
        foreach ($fields as $field) {
            if ($torr[$field] != $row[$field])
                $update[] = "$field = " . $torr[$field];
        }
        if (count($update))
            sql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id");
    }
Reply With Quote
  #2  
Old 31st March 2021, 01:11
darkalchemy darkalchemy is offline
Administrator
 
Join Date: Dec 2017
United States
Posts: 101
Default
Have to checked how long that final query takes?

Depending on the number of torrents, the indexes on the torrents table, the database engine and the amount or ram allotted to mysql, it could take several minutes to run.

If you are using MyISAM then the entire torrents table is locked while this query runs and everything else waits. If you are using InnoDB then only the rows being updated are locked. Could be a significant difference there.
Reply With Quote
  #3  
Old 31st March 2021, 09:56
xblade's Avatar
xblade xblade is offline
Cod3r
 
Join Date: Nov 2020
P2P
Posts: 239
Default
thank you for your post with help on this one the code works very good on Debian 8 MyISAM ive moved to Debian 9.4 MyISAM its only on this i get errors on clean up......and its just one torrent from seedbox and also mate on a home pc its the same on both ends....Every 15 min on clean up we get this.
it shows seeding in seedbox and mate home pc its like its ghosting if you know what i mean...ram ok over 2 GIGS...PHP version: 7.0.33 ...also i took this for a test run on
xampp work ok on pc nps at all
Done test of clean up it is this part of the clean up

Code:
    $fields = explode(":", "comments:leechers:seeders");
    $res = sql_query("SELECT id, seeders, leechers, comments FROM torrents");
    while ($row = mysqli_fetch_assoc($res)) {
        $id = $row["id"];
        $torr = $torrents[$id];
        foreach ($fields as $field) {
            if (!isset($torr[$field]))
                $torr[$field] = 0;
        }
        $update = array();
        foreach ($fields as $field) {
            if ($torr[$field] != $row[$field])
                $update[] = "$field = " . $torr[$field];
        }
        if (count($update))
            sql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id");
    }
that is causeing the probs

Last edited by xblade; 31st March 2021 at 10:16.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 19:33. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.