mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-09 22:47:58 +00:00
add torrent file validation
This commit is contained in:
parent
5aa20e6a22
commit
f919a7ed85
@ -45,7 +45,7 @@ class TorrentController extends AbstractController
|
||||
}
|
||||
|
||||
// Read file
|
||||
if (!$file = $torrentService->readTorrentFileById($torrent->getId()))
|
||||
if (!$file = $torrentService->readTorrentFileByTorrentId($torrent->getId()))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
@ -32,14 +32,22 @@ class TorrentService
|
||||
// Tools
|
||||
public function readTorrentFileByFilepath(
|
||||
string $filepath
|
||||
): \Rhilip\Bencode\TorrentFile
|
||||
): ?\Rhilip\Bencode\TorrentFile
|
||||
{
|
||||
return \Rhilip\Bencode\TorrentFile::load(
|
||||
$filepath
|
||||
);
|
||||
try
|
||||
{
|
||||
return \Rhilip\Bencode\TorrentFile::load(
|
||||
$filepath
|
||||
);
|
||||
}
|
||||
|
||||
catch (\Rhilip\Bencode\ParseException $error)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function readTorrentFileById(
|
||||
public function readTorrentFileByTorrentId(
|
||||
int $id
|
||||
): \Rhilip\Bencode\TorrentFile
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user