fix errors

This commit is contained in:
ghost 2023-10-14 22:01:10 +03:00
parent 20dc122ab2
commit be34befe96

View File

@ -45,15 +45,14 @@ class TorrentService
if ($torrent = $this->getTorrentScrapeQueue()) if ($torrent = $this->getTorrentScrapeQueue())
{ {
// Get file // Init default values
if (!$file = $this->readTorrentFileByTorrentId($torrent->getId())) $seeders = 0;
{ $peers = 0;
// @TODO $leechers = 0;
throw new \Exception(
$translator->trans('File not found')
);
}
// Get file
if ($file = $this->readTorrentFileByTorrentId($torrent->getId()))
{
// Get info hashes // Get info hashes
$hashes = []; $hashes = [];
@ -67,11 +66,6 @@ class TorrentService
$hashes[] = $hash; $hashes[] = $hash;
} }
// Init default values
$seeders = 0;
$peers = 0;
$leechers = 0;
// Get scrape // Get scrape
if ($hashes && $trackers) if ($hashes && $trackers)
{ {
@ -97,6 +91,7 @@ class TorrentService
} }
} }
} }
}
// Update torrent scrape // Update torrent scrape
$torrent->setSeeders( $torrent->setSeeders(
@ -156,7 +151,7 @@ class TorrentService
if ($file = $this->readTorrentFileByFilepath($filepath)) if ($file = $this->readTorrentFileByFilepath($filepath))
{ {
foreach ($file->getFileList() as $file) foreach ($file->getFileList() as $list)
{ {
$words = explode( $words = explode(
' ', ' ',
@ -166,7 +161,7 @@ class TorrentService
preg_replace( preg_replace(
'/[\W]+/', '/[\W]+/',
' ', ' ',
$file['path'] $list['path']
) )
) )
); );