fixed xml providers running over and over

This commit is contained in:
Luke Pulverenti
2013-10-01 14:24:27 -04:00
parent 900266eb54
commit 3d40c5ba36
42 changed files with 323 additions and 395 deletions

View File

@@ -72,10 +72,7 @@ namespace MediaBrowser.Common.Implementations
{
_dataDirectory = Path.Combine(ProgramDataPath, "data");
if (!Directory.Exists(_dataDirectory))
{
Directory.CreateDirectory(_dataDirectory);
}
Directory.CreateDirectory(_dataDirectory);
}
return _dataDirectory;
@@ -98,10 +95,7 @@ namespace MediaBrowser.Common.Implementations
{
_imageCachePath = Path.Combine(CachePath, "images");
if (!Directory.Exists(_imageCachePath))
{
Directory.CreateDirectory(_imageCachePath);
}
Directory.CreateDirectory(_imageCachePath);
}
return _imageCachePath;
@@ -123,10 +117,7 @@ namespace MediaBrowser.Common.Implementations
if (_pluginsPath == null)
{
_pluginsPath = Path.Combine(ProgramDataPath, "plugins");
if (!Directory.Exists(_pluginsPath))
{
Directory.CreateDirectory(_pluginsPath);
}
Directory.CreateDirectory(_pluginsPath);
}
return _pluginsPath;
@@ -148,10 +139,7 @@ namespace MediaBrowser.Common.Implementations
if (_pluginConfigurationsPath == null)
{
_pluginConfigurationsPath = Path.Combine(PluginsPath, "configurations");
if (!Directory.Exists(_pluginConfigurationsPath))
{
Directory.CreateDirectory(_pluginConfigurationsPath);
}
Directory.CreateDirectory(_pluginConfigurationsPath);
}
return _pluginConfigurationsPath;
@@ -170,10 +158,7 @@ namespace MediaBrowser.Common.Implementations
if (_tempUpdatePath == null)
{
_tempUpdatePath = Path.Combine(ProgramDataPath, "updates");
if (!Directory.Exists(_tempUpdatePath))
{
Directory.CreateDirectory(_tempUpdatePath);
}
Directory.CreateDirectory(_tempUpdatePath);
}
return _tempUpdatePath;
@@ -195,10 +180,7 @@ namespace MediaBrowser.Common.Implementations
if (_logDirectoryPath == null)
{
_logDirectoryPath = Path.Combine(ProgramDataPath, "logs");
if (!Directory.Exists(_logDirectoryPath))
{
Directory.CreateDirectory(_logDirectoryPath);
}
Directory.CreateDirectory(_logDirectoryPath);
}
return _logDirectoryPath;
}
@@ -219,10 +201,7 @@ namespace MediaBrowser.Common.Implementations
if (_configurationDirectoryPath == null)
{
_configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");
if (!Directory.Exists(_configurationDirectoryPath))
{
Directory.CreateDirectory(_configurationDirectoryPath);
}
Directory.CreateDirectory(_configurationDirectoryPath);
}
return _configurationDirectoryPath;
}
@@ -256,10 +235,7 @@ namespace MediaBrowser.Common.Implementations
{
_cachePath = Path.Combine(ProgramDataPath, "cache");
if (!Directory.Exists(_cachePath))
{
Directory.CreateDirectory(_cachePath);
}
Directory.CreateDirectory(_cachePath);
}
return _cachePath;
@@ -282,10 +258,7 @@ namespace MediaBrowser.Common.Implementations
{
_tempDirectory = Path.Combine(CachePath, "temp");
if (!Directory.Exists(_tempDirectory))
{
Directory.CreateDirectory(_tempDirectory);
}
Directory.CreateDirectory(_tempDirectory);
}
return _tempDirectory;
@@ -318,10 +291,7 @@ namespace MediaBrowser.Common.Implementations
programDataPath = Path.GetFullPath(programDataPath);
}
if (!Directory.Exists(programDataPath))
{
Directory.CreateDirectory(programDataPath);
}
Directory.CreateDirectory(programDataPath);
return programDataPath;
}

View File

@@ -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.
}
}
/// <summary>
/// Validates the params.
/// </summary>

View File

@@ -431,7 +431,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{
var path = Path.Combine(ApplicationPaths.ConfigurationDirectoryPath, "ScheduledTasks");
if (create && !Directory.Exists(path))
if (create)
{
Directory.CreateDirectory(path);
}
@@ -448,7 +448,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{
var path = Path.Combine(ApplicationPaths.DataPath, "ScheduledTasks");
if (create && !Directory.Exists(path))
if (create)
{
Directory.CreateDirectory(path);
}
@@ -507,10 +507,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
var parentPath = Path.GetDirectoryName(path);
if (!Directory.Exists(parentPath))
{
Directory.CreateDirectory(parentPath);
}
Directory.CreateDirectory(parentPath);
JsonSerializer.SerializeToFile(triggers.Select(ScheduledTaskHelpers.GetTriggerInfo), path);
}