New: Log content for invalid torrent files

This commit is contained in:
Bogdan 2023-05-06 21:22:49 +03:00 committed by GitHub
parent ca8b26138e
commit e3f71ca79c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,6 @@
using MonoTorrent;
using System.Text;
using MonoTorrent;
using NLog;
namespace NzbDrone.Core.MediaFiles.TorrentInfo
{
@ -9,9 +11,24 @@ namespace NzbDrone.Core.MediaFiles.TorrentInfo
public class TorrentFileInfoReader : ITorrentFileInfoReader
{
private readonly Logger _logger;
public TorrentFileInfoReader(Logger logger)
{
_logger = logger;
}
public string GetHashFromTorrentFile(byte[] fileContents)
{
return Torrent.Load(fileContents).InfoHash.ToHex();
try
{
return Torrent.Load(fileContents).InfoHash.ToHex();
}
catch
{
_logger.Trace("Invalid torrent file contents: {0}", Encoding.ASCII.GetString(fileContents));
throw;
}
}
}
}