mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
load pieces hash skip error torrent
This commit is contained in:
@@ -33,7 +33,7 @@ class TorrentLoadPiecesHash extends Command
|
||||
$rep = new TorrentRepository();
|
||||
$this->info("id: $id, going to load pieces hash...");
|
||||
$total = $rep->loadPiecesHashCache($id);
|
||||
$this->info(sprintf("total: %s, cost time: %s seconds.", $total, time() - $begin));
|
||||
$this->info(sprintf("%s, total: %s, cost time: %s seconds.", nexus()->getRequestId(), $total, time() - $begin));
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,17 +825,24 @@ HTML;
|
||||
}
|
||||
$pipe = NexusDB::redis()->multi(\Redis::PIPELINE);
|
||||
$piecesHashCaseWhen = $updateIdArr = [];
|
||||
$count = 0;
|
||||
foreach ($list as $item) {
|
||||
$piecesHash = $item->pieces_hash;
|
||||
if (!$piecesHash) {
|
||||
$torrentFile = $torrentDir . $item->id . ".torrent";
|
||||
$loadResult = Bencode::load($torrentFile);
|
||||
$piecesHash = sha1($loadResult['info']['pieces']);
|
||||
$piecesHashCaseWhen[] = sprintf("when %s then '%s'", $item->id, $piecesHash);
|
||||
$updateIdArr[] = $item->id;
|
||||
do_log(sprintf("torrent: %s no pieces hash, load from torrent file: %s, pieces hash: %s", $item->id, $torrentFile, $piecesHash));
|
||||
try {
|
||||
$piecesHash = $item->pieces_hash;
|
||||
if (!$piecesHash) {
|
||||
$torrentFile = $torrentDir . $item->id . ".torrent";
|
||||
$loadResult = Bencode::load($torrentFile);
|
||||
$piecesHash = sha1($loadResult['info']['pieces']);
|
||||
$piecesHashCaseWhen[] = sprintf("when %s then '%s'", $item->id, $piecesHash);
|
||||
$updateIdArr[] = $item->id;
|
||||
do_log(sprintf("torrent: %s no pieces hash, load from torrent file: %s, pieces hash: %s", $item->id, $torrentFile, $piecesHash));
|
||||
}
|
||||
$pipe->hSet(self::PIECES_HASH_CACHE_KEY, $piecesHash, $this->buildPiecesHashCacheValue($item->id, $piecesHash));
|
||||
$total++;
|
||||
$count++;
|
||||
} catch (\Exception $exception) {
|
||||
do_log(sprintf("load pieces hash of torrent: %s error: %s", $item->id, $exception->getMessage()), 'error');
|
||||
}
|
||||
$pipe->hSet(self::PIECES_HASH_CACHE_KEY, $piecesHash, $this->buildPiecesHashCacheValue($item->id, $piecesHash));
|
||||
}
|
||||
$pipe->exec();
|
||||
if (!empty($piecesHashCaseWhen)) {
|
||||
@@ -846,8 +853,6 @@ HTML;
|
||||
);
|
||||
NexusDB::statement($sql);
|
||||
}
|
||||
$count = $list->count();
|
||||
$total += $count;
|
||||
do_log("success load page: $page, size: $size, count: $count");
|
||||
$page++;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.6');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-07-30');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-07-31');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
Reference in New Issue
Block a user