From fb69ce76e048acd276567b9c54f428bb0adccbfc Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Fri, 28 Jun 2019 19:05:04 -0500 Subject: [PATCH] don't eat perf cost of exceptions for not supported extensions --- .../ListArchiver/DownloadList.cs | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/src/FilterLists.Agent/ListArchiver/DownloadList.cs b/src/FilterLists.Agent/ListArchiver/DownloadList.cs index ad17312c5..b6244fd20 100644 --- a/src/FilterLists.Agent/ListArchiver/DownloadList.cs +++ b/src/FilterLists.Agent/ListArchiver/DownloadList.cs @@ -30,30 +30,30 @@ private static readonly Dictionary> DownloadReq = new Dictionary> { {"", l => new DownloadTxt.Command(l)}, - {".7z", l => throw new NotImplementedException()}, - {".acl", l => throw new NotImplementedException()}, - {".action", l => throw new NotImplementedException()}, - {".all", l => throw new NotImplementedException()}, - {".aspx", l => throw new NotImplementedException()}, - {".bat", l => throw new NotImplementedException()}, - {".blacklist", l => throw new NotImplementedException()}, - {".conf", l => throw new NotImplementedException()}, - {".csv", l => throw new NotImplementedException()}, - {".dat", l => throw new NotImplementedException()}, - {".deny", l => throw new NotImplementedException()}, - {".host", l => throw new NotImplementedException()}, - {".hosts", l => throw new NotImplementedException()}, - {".ips", l => throw new NotImplementedException()}, - {".ipset", l => throw new NotImplementedException()}, - {".json", l => throw new NotImplementedException()}, - {".list", l => throw new NotImplementedException()}, - {".lsrules", l => throw new NotImplementedException()}, - {".netset", l => throw new NotImplementedException()}, - {".p2p", l => throw new NotImplementedException()}, - {".php", l => throw new NotImplementedException()}, - {".tpl", l => throw new NotImplementedException()}, - {".txt", l => new DownloadTxt.Command(l)}, - {".zip", l => throw new NotImplementedException()} + //{".7z", l => throw new NotImplementedException()}, + //{".acl", l => throw new NotImplementedException()}, + //{".action", l => throw new NotImplementedException()}, + //{".all", l => throw new NotImplementedException()}, + //{".aspx", l => throw new NotImplementedException()}, + //{".bat", l => throw new NotImplementedException()}, + //{".blacklist", l => throw new NotImplementedException()}, + //{".conf", l => throw new NotImplementedException()}, + //{".csv", l => throw new NotImplementedException()}, + //{".dat", l => throw new NotImplementedException()}, + //{".deny", l => throw new NotImplementedException()}, + //{".host", l => throw new NotImplementedException()}, + //{".hosts", l => throw new NotImplementedException()}, + //{".ips", l => throw new NotImplementedException()}, + //{".ipset", l => throw new NotImplementedException()}, + //{".json", l => throw new NotImplementedException()}, + //{".list", l => throw new NotImplementedException()}, + //{".lsrules", l => throw new NotImplementedException()}, + //{".netset", l => throw new NotImplementedException()}, + //{".p2p", l => throw new NotImplementedException()}, + //{".php", l => throw new NotImplementedException()}, + //{".tpl", l => throw new NotImplementedException()}, + {".txt", l => new DownloadTxt.Command(l)} + //{".zip", l => throw new NotImplementedException()} }; private readonly ILogger _logger; @@ -67,15 +67,7 @@ public Handler(ILogger logger, IMediator mediator) protected override async Task Handle(Command request, CancellationToken cancellationToken) { - try - { - await DownloadByFileExtension(request, cancellationToken); - } - catch (NotImplementedException) - { - _logger.LogWarning( - $"File extension not supported for list {request.ListInfo.Id} from {request.ListInfo.ViewUrl}."); - } + await DownloadByFileExtension(request, cancellationToken); } private async Task DownloadByFileExtension(Command request, CancellationToken cancellationToken) @@ -91,7 +83,7 @@ await _mediator.Send(DownloadRequestsByFileExtension[extension].Invoke(request.L else { _logger.LogWarning( - $"File extension not recognized for list {request.ListInfo.Id} from {request.ListInfo.ViewUrl}."); + $"File extension not supported for list {request.ListInfo.Id} from {request.ListInfo.ViewUrl}."); } } }