Browse Source

add torrent file validation

main
ghost 1 year ago
parent
commit
f919a7ed85
  1. 2
      src/Controller/TorrentController.php
  2. 12
      src/Service/TorrentService.php

2
src/Controller/TorrentController.php

@ -45,7 +45,7 @@ class TorrentController extends AbstractController
} }
// Read file // Read file
if (!$file = $torrentService->readTorrentFileById($torrent->getId())) if (!$file = $torrentService->readTorrentFileByTorrentId($torrent->getId()))
{ {
throw $this->createNotFoundException(); throw $this->createNotFoundException();
} }

12
src/Service/TorrentService.php

@ -32,14 +32,22 @@ class TorrentService
// Tools // Tools
public function readTorrentFileByFilepath( public function readTorrentFileByFilepath(
string $filepath string $filepath
): \Rhilip\Bencode\TorrentFile ): ?\Rhilip\Bencode\TorrentFile
{
try
{ {
return \Rhilip\Bencode\TorrentFile::load( return \Rhilip\Bencode\TorrentFile::load(
$filepath $filepath
); );
} }
public function readTorrentFileById( catch (\Rhilip\Bencode\ParseException $error)
{
return null;
}
}
public function readTorrentFileByTorrentId(
int $id int $id
): \Rhilip\Bencode\TorrentFile ): \Rhilip\Bencode\TorrentFile
{ {

Loading…
Cancel
Save