From 3d40c5ba36c5e98954c2bc6073b4cf35cd42711a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 1 Oct 2013 14:24:27 -0400 Subject: fixed xml providers running over and over --- .../HttpClientManager/HttpClientManager.cs | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs') diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 550fe9593..3a626000f 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -220,10 +220,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager { options.ResourcePool.Release(); } - + throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true }; } - + _logger.Info("HttpClientManager.Get url: {0}", options.Url); try @@ -512,10 +512,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager if (operationCanceledException != null) { // Cleanup - if (File.Exists(tempFile)) - { - File.Delete(tempFile); - } + DeleteTempFile(tempFile); return GetCancellationException(options.Url, options.CancellationToken, operationCanceledException); } @@ -525,10 +522,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager var httpRequestException = ex as HttpRequestException; // Cleanup - if (File.Exists(tempFile)) - { - File.Delete(tempFile); - } + DeleteTempFile(tempFile); if (httpRequestException != null) { @@ -538,6 +532,18 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager return ex; } + private void DeleteTempFile(string file) + { + try + { + File.Delete(file); + } + catch (IOException) + { + // Might not have been created at all. No need to worry. + } + } + /// /// Validates the params. /// -- cgit v1.2.3