1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2025-02-25 07:12:40 +00:00

New: Log content for invalid torrent files

(cherry picked from commit e3f71ca79c3c92015e6c3fc292ae3124dab63410)
This commit is contained in:
Bogdan 2023-05-06 21:22:49 +03:00
parent 565c05c4c9
commit 83224884f7

View file

@ -1,4 +1,6 @@
using MonoTorrent;
using System.Text;
using MonoTorrent;
using NLog;
namespace NzbDrone.Core.MediaFiles.TorrentInfo
{
@ -9,9 +11,24 @@ public interface ITorrentFileInfoReader
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;
}
}
}
}