aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common.Implementations')
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationPaths.cs50
-rw-r--r--MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs26
-rw-r--r--MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs9
3 files changed, 29 insertions, 56 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
index c177bd1ed..bee5e5dc4 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs
@@ -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;
}
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.
+ }
+ }
+
/// <summary>
/// Validates the params.
/// </summary>
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index 8947bdcc0..fbdbf15ff 100644
--- a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -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);
}