aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-06-03 22:02:49 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-06-03 22:02:49 -0400
commit02fedead11f738c09e503c3bdc74e2dd98e21cc8 (patch)
tree5e32fb80c23fa910dbdd0cc6a8be6bf105abd631 /MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
parent08d9004d8f361aaf13756cab70fc659e5fbb775c (diff)
re-factored some file system access
Diffstat (limited to 'MediaBrowser.Server.Implementations/Providers/ProviderManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Providers/ProviderManager.cs15
1 files changed, 11 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
index 2ba222ca5..ea1b83dec 100644
--- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
+++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
@@ -328,9 +328,7 @@ namespace MediaBrowser.Server.Implementations.Providers
public async Task<string> SaveImage(BaseItem item, Stream source, string targetName, bool saveLocally, CancellationToken cancellationToken)
{
//download and save locally
- var localPath = (saveLocally && item.MetaLocation != null) ?
- Path.Combine(item.MetaLocation, targetName) :
- _remoteImageCache.GetResourcePath(item.GetType().FullName + item.Path.ToLower(), targetName);
+ var localPath = GetSavePath(item, targetName, saveLocally);
if (saveLocally) // queue to media directories
{
@@ -374,9 +372,18 @@ namespace MediaBrowser.Server.Implementations.Providers
/// <returns>System.String.</returns>
public string GetSavePath(BaseItem item, string targetFileName, bool saveLocally)
{
- return (saveLocally && item.MetaLocation != null) ?
+ var path = (saveLocally && item.MetaLocation != null) ?
Path.Combine(item.MetaLocation, targetFileName) :
_remoteImageCache.GetResourcePath(item.GetType().FullName + item.Id.ToString(), targetFileName);
+
+ var parentPath = Path.GetDirectoryName(path);
+
+ if (!Directory.Exists(parentPath))
+ {
+ Directory.CreateDirectory(parentPath);
+ }
+
+ return path;
}
/// <summary>