Update logchecker to 0.14.2 / add rescore-logs script

This commit is contained in:
itismadness
2025-09-29 03:53:43 +00:00
committed by Spine
parent 39cd6fc2b4
commit c1bd4522b0
4 changed files with 114 additions and 10 deletions

View File

@@ -186,7 +186,7 @@ class Torrent extends TorrentAbstract {
return $affected;
}
public function rescoreLog(int $logId, Logfile $logfile, string $version): int {
public function rescoreLog(int $logId, Logfile $logfile, string $version, bool $modifyLogscore = true): int {
self::$db->prepared_query("
UPDATE torrents_logs SET
Score = ?, `Checksum` = ?, ChecksumState = ?, Ripper = ?, RipperVersion = ?,
@@ -197,7 +197,7 @@ class Torrent extends TorrentAbstract {
$logfile->language(), $logfile->detailsAsString(), $version,
$this->id, $logId
);
if (self::$db->affected_rows() > 0) {
if ($modifyLogscore && self::$db->affected_rows() > 0) {
return $this->modifyLogscore();
}
return 0;

104
bin/rescore-logs Executable file
View File

@@ -0,0 +1,104 @@
#! /usr/bin/env php
<?php
/**
* Script to clean broken uploads
*
* Usage: rescore-logs [--dry-run] [--limit <n>] [--offset <n>]
*/
namespace Gazelle;
use OrpheusNET\Logchecker\Logchecker;
require_once(__DIR__ . '/../lib/bootstrap.php');
$dryRun = in_array('--dry-run', $argv);
$limitKey = array_find_key($argv, fn ($val) => $val === '--limit');
if ($limitKey !== null) {
if (!isset($argv[$limitKey + 1]) || !is_numeric($argv[$limitKey + 1])) {
die("If you specify --limit, you must also provide a numeric limit\n");
}
$limit = (int)$argv[$limitKey + 1];
} else {
$limit = PHP_INT_MAX;
}
$offsetKey = array_find_key($argv, fn ($val) => $val === '--offset');
if ($offsetKey !== null) {
if (!isset($argv[$offsetKey + 1]) || !is_numeric($argv[$offsetKey + 1])) {
die("If you specify --offset, you must also provide a numeric offset\n");
}
$offset = (int)$argv[$offsetKey + 1];
} else {
$offset = 0;
}
$logcheckerVersion = Logchecker::getLogcheckerVersion();
[$major, $minor, $patch] = explode('.', $logcheckerVersion);
$db = DB::DB();
$db->prepared_query("
SELECT TorrentID, LogID, Score
FROM torrents_logs
WHERE
LogcheckerVersion = ''
OR CAST(SUBSTRING_INDEX(LogcheckerVersion, '.', 1) AS UNSIGNED) < ?
OR (
CAST(SUBSTRING_INDEX(LogcheckerVersion, '.', 1) AS UNSIGNED) = ? AND
CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(LogcheckerVersion, '.', 2), '.', -1) AS UNSIGNED) < ?
)
OR (
CAST(SUBSTRING_INDEX(LogcheckerVersion, '.', 1) AS UNSIGNED) = ? AND
CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(LogcheckerVersion, '.', 2), '.', -1) AS UNSIGNED) = ? AND
CAST(SUBSTRING_INDEX(LogcheckerVersion, '.', -1) AS UNSIGNED) < ?
)
ORDER BY LogID, TorrentID
LIMIT ? OFFSET ?
", $major, $major, $minor, $major, $minor, $patch, $limit, $offset);
$i = 0;
/** @var Torrent|null */
$torrent = null;
while (true) {
$row = $db->next_row(MYSQLI_NUM);
if (!$row) {
if (!$dryRun) {
$torrent?->modifyLogscore();
}
break;
}
[$torrentId, $logId, $score] = $row;
if (!$torrent || $torrent->id() !== $torrentId) {
if (!$dryRun) {
$torrent?->modifyLogscore();
}
$torrent = new Torrent($torrentId);
$rescore = false;
}
$logpath = new File\RipLog($torrent->id, $logId)->path();
$logfile = new Logfile($logpath, basename($logpath));
echo sprintf(
"%d: torrent %d - log %d (%s): %d -> %d\n",
$i,
$torrent->id(),
$logId,
$logpath,
$score,
$logfile->score()
);
if (!$dryRun) {
new File\RipLogHTML($torrent->id, $logId)->put($logfile->text());
$torrent->rescoreLog($logId, $logfile, Logchecker::getLogcheckerVersion(), false);
}
$i++;
}

View File

@@ -34,7 +34,7 @@
"maennchen/zipstream-php": "^3.1",
"monero-integrations/monerophp": "dev-master#25d4c5838b35cbf1fb55170b831e895681a7410a",
"orpheusnet/bencode-torrent": "^1.3.0",
"orpheusnet/logchecker": "^0.14.1",
"orpheusnet/logchecker": "^0.14.2",
"protonlabs/bitcoin": "^1.0",
"robmorgan/phinx": "^0.16",
"robthree/twofactorauth": "^1.8.2",

14
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "29ff371adb62c2570ef7860b15ef1953",
"content-hash": "321c857e2383b26015bc2d0ac2888083",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@ -1202,16 +1202,16 @@
},
{
"name": "orpheusnet/logchecker",
"version": "0.14.1",
"version": "0.14.2",
"source": {
"type": "git",
"url": "https://github.com/OPSnet/Logchecker.git",
"reference": "e899a7819eaeda759f3122b80f5f6a20d8ec33d6"
"reference": "66d93bc78dabf9f6a1a14dbf2753ee90569887d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/OPSnet/Logchecker/zipball/e899a7819eaeda759f3122b80f5f6a20d8ec33d6",
"reference": "e899a7819eaeda759f3122b80f5f6a20d8ec33d6",
"url": "https://api.github.com/repos/OPSnet/Logchecker/zipball/66d93bc78dabf9f6a1a14dbf2753ee90569887d7",
"reference": "66d93bc78dabf9f6a1a14dbf2753ee90569887d7",
"shasum": ""
},
"require": {
@@ -1257,9 +1257,9 @@
"description": "Logchecker for validating logs generated from supported ripping programs (like EAC and XLD)",
"support": {
"issues": "https://github.com/OPSnet/Logchecker/issues",
"source": "https://github.com/OPSnet/Logchecker/tree/0.14.1"
"source": "https://github.com/OPSnet/Logchecker/tree/0.14.2"
},
"time": "2025-08-14T21:17:05+00:00"
"time": "2025-09-14T02:12:48+00:00"
},
{
"name": "pleonasm/merkle-tree",