re-factored some file system access

This commit is contained in:
Luke Pulverenti
2013-06-03 22:02:49 -04:00
parent 08d9004d8f
commit 02fedead11
24 changed files with 339 additions and 258 deletions

View File

@@ -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>