Merge pull request #2613 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2017-05-04 15:05:22 -04:00 committed by GitHub
commit 6e53aa0e07
82 changed files with 261 additions and 289 deletions

View File

@ -96,7 +96,7 @@ namespace BDInfo
}
DirectoryRoot =
_fileSystem.GetDirectoryInfo(Path.GetDirectoryName(DirectoryBDMV.FullName));
_fileSystem.GetDirectoryInfo(_fileSystem.GetDirectoryName(DirectoryBDMV.FullName));
DirectoryBDJO =
GetDirectory("BDJO", DirectoryBDMV, 0);
DirectoryCLIPINF =
@ -349,7 +349,7 @@ namespace BDInfo
{
return dir;
}
var parentFolder = Path.GetDirectoryName(dir.FullName);
var parentFolder = _fileSystem.GetDirectoryName(dir.FullName);
if (string.IsNullOrEmpty(parentFolder))
{
dir = null;

View File

@ -57,7 +57,7 @@ namespace Emby.Common.Implementations.Devices
{
var path = CachePath;
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
lock (_syncLock)
{

View File

@ -418,7 +418,7 @@ namespace Emby.Common.Implementations.HttpClientManager
private async Task CacheResponse(HttpResponseInfo response, string responseCachePath)
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(responseCachePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(responseCachePath));
using (var responseStream = response.Content)
{

View File

@ -546,24 +546,6 @@ namespace Emby.Common.Implementations.IO
return Path.DirectorySeparatorChar;
}
public bool AreEqual(string path1, string path2)
{
if (path1 == null && path2 == null)
{
return true;
}
if (path1 == null || path2 == null)
{
return false;
}
path1 = path1.TrimEnd(GetDirectorySeparatorChar(path1));
path2 = path2.TrimEnd(GetDirectorySeparatorChar(path2));
return string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase);
}
public bool ContainsSubPath(string parentPath, string path)
{
if (string.IsNullOrEmpty(parentPath))
@ -588,7 +570,7 @@ namespace Emby.Common.Implementations.IO
throw new ArgumentNullException("path");
}
var parent = Path.GetDirectoryName(path);
var parent = GetDirectoryName(path);
if (!string.IsNullOrEmpty(parent))
{
@ -598,6 +580,16 @@ namespace Emby.Common.Implementations.IO
return true;
}
public string GetDirectoryName(string path)
{
if (_sharpCifsFileSystem.IsEnabledForPath(path))
{
return _sharpCifsFileSystem.GetDirectoryName(path);
}
return Path.GetDirectoryName(path);
}
public string NormalizePath(string path)
{
if (string.IsNullOrEmpty(path))
@ -605,6 +597,11 @@ namespace Emby.Common.Implementations.IO
throw new ArgumentNullException("path");
}
if (_sharpCifsFileSystem.IsEnabledForPath(path))
{
return _sharpCifsFileSystem.NormalizePath(path);
}
if (path.EndsWith(":\\", StringComparison.OrdinalIgnoreCase))
{
return path;
@ -613,6 +610,21 @@ namespace Emby.Common.Implementations.IO
return path.TrimEnd(GetDirectorySeparatorChar(path));
}
public bool AreEqual(string path1, string path2)
{
if (path1 == null && path2 == null)
{
return true;
}
if (path1 == null || path2 == null)
{
return false;
}
return string.Equals(NormalizePath(path1), NormalizePath(path2), StringComparison.OrdinalIgnoreCase);
}
public string GetFileNameWithoutExtension(FileSystemMetadata info)
{
if (info.IsDirectory)
@ -637,11 +649,17 @@ namespace Emby.Common.Implementations.IO
// Cannot use Path.IsPathRooted because it returns false under mono when using windows-based paths, e.g. C:\\
if (_sharpCifsFileSystem.IsEnabledForPath(path))
{
return true;
}
if (path.IndexOf("://", StringComparison.OrdinalIgnoreCase) != -1 &&
!path.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
{
return false;
}
return true;
//return Path.IsPathRooted(path);

View File

@ -30,6 +30,34 @@ namespace Emby.Common.Implementations.IO
return path.StartsWith("smb://", StringComparison.OrdinalIgnoreCase) || IsUncPath(path);
}
public string NormalizePath(string path)
{
if (path.StartsWith("smb://", StringComparison.OrdinalIgnoreCase))
{
return path;
}
if (IsUncPath(path))
{
return ConvertUncToSmb(path);
}
return path;
}
public string GetDirectoryName(string path)
{
var separator = GetDirectorySeparatorChar(path);
var result = Path.GetDirectoryName(path);
if (separator == '/')
{
result = result.Replace('\\', '/');
}
return result;
}
public char GetDirectorySeparatorChar(string path)
{
if (path.IndexOf('/') != -1)

View File

@ -158,7 +158,7 @@ namespace Emby.Common.Implementations.ScheduledTasks
_lastExecutionResult = value;
var path = GetHistoryFilePath();
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
lock (_lastExecutionResultSyncLock)
{
@ -575,7 +575,7 @@ namespace Emby.Common.Implementations.ScheduledTasks
{
var path = GetConfigurationFilePath();
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
JsonSerializer.SerializeToFile(triggers, path);
}

View File

@ -91,7 +91,7 @@ namespace Emby.Drawing.ImageMagick
try
{
var tmpPath = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid() + ".webp");
_fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(tmpPath));
using (var wand = new MagickWand(1, 1, new PixelWand("none", 1)))
{

View File

@ -68,7 +68,7 @@ namespace Emby.Drawing.ImageMagick
var namespacePath = typeof(PlayedIndicatorDrawer).Namespace + ".fonts." + name;
var tempPath = Path.Combine(paths.TempDirectory, Guid.NewGuid().ToString("N") + ".ttf");
fileSystem.CreateDirectory(Path.GetDirectoryName(tempPath));
fileSystem.CreateDirectory(fileSystem.GetDirectoryName(tempPath));
using (var stream = typeof(PlayedIndicatorDrawer).Assembly.GetManifestResourceStream(namespacePath))
{
@ -78,7 +78,7 @@ namespace Emby.Drawing.ImageMagick
}
}
fileSystem.CreateDirectory(Path.GetDirectoryName(filePath));
fileSystem.CreateDirectory(fileSystem.GetDirectoryName(filePath));
try
{
@ -108,7 +108,7 @@ namespace Emby.Drawing.ImageMagick
}).ConfigureAwait(false);
fileSystem.CreateDirectory(Path.GetDirectoryName(filePath));
fileSystem.CreateDirectory(fileSystem.GetDirectoryName(filePath));
try
{

View File

@ -81,7 +81,7 @@ namespace Emby.Drawing.Net
{
using (var croppedImage = image.CropWhitespace())
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(outputPath));
using (var outputStream = _fileSystem.GetFileStream(outputPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, false))
{
@ -135,7 +135,7 @@ namespace Emby.Drawing.Net
var outputFormat = GetOutputFormat(originalImage, selectedOutputFormat);
_fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath));
// Save to the cache location
using (var cacheFileStream = _fileSystem.GetFileStream(cacheFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, false))

View File

@ -244,9 +244,9 @@ namespace Emby.Drawing
var newWidth = Convert.ToInt32(newSize.Width);
var newHeight = Convert.ToInt32(newSize.Height);
_fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath));
var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath));
_fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(tmpPath));
_imageEncoder.EncodeImage(originalImagePath, tmpPath, AutoOrient(options.Item), newWidth, newHeight, quality, options, outputFormat);
CopyFile(tmpPath, cacheFilePath);
@ -418,9 +418,9 @@ namespace Emby.Drawing
try
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(croppedImagePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(croppedImagePath));
var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(croppedImagePath));
_fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(tmpPath));
_imageEncoder.CropWhiteSpace(originalImagePath, tmpPath);
CopyFile(tmpPath, croppedImagePath);
@ -592,7 +592,7 @@ namespace Emby.Drawing
try
{
var path = ImageSizeFile;
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
_jsonSerializer.SerializeToFile(_cachedImagedSizes, path);
}
catch (Exception ex)
@ -765,10 +765,10 @@ namespace Emby.Drawing
return enhancedImagePath;
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(enhancedImagePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(enhancedImagePath));
var tmpPath = Path.Combine(_appPaths.TempDirectory, Path.ChangeExtension(Guid.NewGuid().ToString(), Path.GetExtension(enhancedImagePath)));
_fileSystem.CreateDirectory(Path.GetDirectoryName(tmpPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(tmpPath));
await ExecuteImageEnhancers(supportedEnhancers, originalImagePath, tmpPath, item, imageType, imageIndex).ConfigureAwait(false);

View File

@ -1145,7 +1145,7 @@ namespace Emby.Server.Core
{
if (!FileSystemManager.FileExists(certPath))
{
FileSystemManager.CreateDirectory(Path.GetDirectoryName(certPath));
FileSystemManager.CreateDirectory(FileSystemManager.GetDirectoryName(certPath));
try
{

View File

@ -453,7 +453,7 @@ namespace Emby.Server.Core.IO
// If the parent of an ignored path has a change event, ignore that too
if (tempIgnorePaths.Any(i =>
{
if (string.Equals(i, path, StringComparison.OrdinalIgnoreCase))
if (_fileSystem.AreEqual(i, path))
{
Logger.Debug("Ignoring change to {0}", path);
return true;
@ -466,10 +466,10 @@ namespace Emby.Server.Core.IO
}
// Go up a level
var parent = Path.GetDirectoryName(i);
var parent = _fileSystem.GetDirectoryName(i);
if (!string.IsNullOrEmpty(parent))
{
if (string.Equals(parent, path, StringComparison.OrdinalIgnoreCase))
if (_fileSystem.AreEqual(parent, path))
{
Logger.Debug("Ignoring change to {0}", path);
return true;
@ -492,7 +492,7 @@ namespace Emby.Server.Core.IO
private void CreateRefresher(string path)
{
var parentPath = Path.GetDirectoryName(path);
var parentPath = _fileSystem.GetDirectoryName(path);
lock (_activeRefreshers)
{
@ -500,7 +500,7 @@ namespace Emby.Server.Core.IO
foreach (var refresher in refreshers)
{
// Path is already being refreshed
if (string.Equals(path, refresher.Path, StringComparison.Ordinal))
if (_fileSystem.AreEqual(path, refresher.Path))
{
refresher.RestartTimer();
return;
@ -521,7 +521,7 @@ namespace Emby.Server.Core.IO
}
// They are siblings. Rebase the refresher to the parent folder.
if (string.Equals(parentPath, Path.GetDirectoryName(refresher.Path), StringComparison.Ordinal))
if (string.Equals(parentPath, _fileSystem.GetDirectoryName(refresher.Path), StringComparison.Ordinal))
{
refresher.ResetPath(parentPath, path);
return;

View File

@ -268,7 +268,7 @@ namespace Emby.Server.Implementations.Channels
return;
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
_jsonSerializer.SerializeToFile(mediaSources, path);
}
@ -1105,7 +1105,7 @@ namespace Emby.Server.Implementations.Channels
{
try
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
_jsonSerializer.SerializeToFile(result, path);
}

View File

@ -352,7 +352,7 @@ namespace Emby.Server.Implementations.FileOrganization
_libraryMonitor.ReportFileSystemChangeBeginning(path);
var renameRelatedFiles = !hasRenamedFiles &&
string.Equals(Path.GetDirectoryName(path), Path.GetDirectoryName(result.TargetPath), StringComparison.OrdinalIgnoreCase);
string.Equals(_fileSystem.GetDirectoryName(path), _fileSystem.GetDirectoryName(result.TargetPath), StringComparison.OrdinalIgnoreCase);
if (renameRelatedFiles)
{
@ -432,7 +432,7 @@ namespace Emby.Server.Implementations.FileOrganization
// Now find other files
var originalFilenameWithoutExtension = Path.GetFileNameWithoutExtension(path);
var directory = Path.GetDirectoryName(path);
var directory = _fileSystem.GetDirectoryName(path);
if (!string.IsNullOrWhiteSpace(originalFilenameWithoutExtension) && !string.IsNullOrWhiteSpace(directory))
{
@ -445,7 +445,7 @@ namespace Emby.Server.Implementations.FileOrganization
foreach (var file in files)
{
directory = Path.GetDirectoryName(file);
directory = _fileSystem.GetDirectoryName(file);
var filename = Path.GetFileName(file);
filename = filename.Replace(originalFilenameWithoutExtension, targetFilenameWithoutExtension,
@ -499,7 +499,7 @@ namespace Emby.Server.Implementations.FileOrganization
.Select(i => i.Path)
.ToList();
var folder = Path.GetDirectoryName(targetPath);
var folder = _fileSystem.GetDirectoryName(targetPath);
var targetFileNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(targetPath);
try
@ -529,7 +529,7 @@ namespace Emby.Server.Implementations.FileOrganization
_libraryMonitor.ReportFileSystemChangeBeginning(result.TargetPath);
_fileSystem.CreateDirectory(Path.GetDirectoryName(result.TargetPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(result.TargetPath));
var targetAlreadyExists = _fileSystem.FileExists(result.TargetPath);

View File

@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.IO
{
item = LibraryManager.FindByPath(path, null);
path = System.IO.Path.GetDirectoryName(path);
path = _fileSystem.GetDirectoryName(path);
}
if (item != null)

View File

@ -139,7 +139,7 @@ namespace Emby.Server.Implementations.Images
CancellationToken cancellationToken)
{
var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N"));
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPathWithoutExtension));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPathWithoutExtension));
string outputPath = await CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(outputPath))
@ -205,7 +205,7 @@ namespace Emby.Server.Implementations.Images
private async Task<string> CreateCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
{
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath));
var options = new ImageCollageOptions
{

View File

@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Library
{
if (parent == null)
{
var parentFolderName = Path.GetFileName(Path.GetDirectoryName(path));
var parentFolderName = Path.GetFileName(_fileSystem.GetDirectoryName(path));
if (string.Equals(parentFolderName, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
{

View File

@ -1962,8 +1962,34 @@ namespace Emby.Server.Implementations.Library
return new List<Folder>();
}
return GetUserRootFolder().Children
.OfType<Folder>()
return GetCollectionFoldersInternal(item, GetUserRootFolder().Children.OfType<Folder>().ToList());
}
public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren)
{
while (item != null)
{
var parent = item.GetParent();
if (parent == null || parent is AggregateFolder)
{
break;
}
item = parent;
}
if (item == null)
{
return new List<Folder>();
}
return GetCollectionFoldersInternal(item, allUserRootChildren);
}
private List<Folder> GetCollectionFoldersInternal(BaseItem item, List<Folder> allUserRootChildren)
{
return allUserRootChildren
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path, StringComparer.OrdinalIgnoreCase))
.ToList();
}

View File

@ -6,6 +6,7 @@ using System;
using System.IO;
using System.Linq;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
namespace Emby.Server.Implementations.Library.Resolvers
{
@ -13,11 +14,13 @@ namespace Emby.Server.Implementations.Library.Resolvers
{
private readonly IImageProcessor _imageProcessor;
private readonly ILibraryManager _libraryManager;
private readonly IFileSystem _fileSystem;
public PhotoResolver(IImageProcessor imageProcessor, ILibraryManager libraryManager)
public PhotoResolver(IImageProcessor imageProcessor, ILibraryManager libraryManager, IFileSystem fileSystem)
{
_imageProcessor = imageProcessor;
_libraryManager = libraryManager;
_fileSystem = fileSystem;
}
/// <summary>
@ -41,7 +44,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
var filename = Path.GetFileNameWithoutExtension(args.Path);
// Make sure the image doesn't belong to a video file
if (args.DirectoryService.GetFilePaths(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename)))
if (args.DirectoryService.GetFilePaths(_fileSystem.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename)))
{
return null;
}

View File

@ -965,7 +965,7 @@ namespace Emby.Server.Implementations.Library
var path = GetPolifyFilePath(user);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
lock (_policySyncLock)
{
@ -1052,7 +1052,7 @@ namespace Emby.Server.Implementations.Library
config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
lock (_configSyncLock)
{

View File

@ -1497,7 +1497,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_libraryManager.RegisterIgnoredPath(recordPath);
_libraryMonitor.ReportFileSystemChangeBeginning(recordPath);
_fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(recordPath));
activeRecordingInfo.Path = recordPath;
var duration = recordingEndDate - DateTime.UtcNow;
@ -1725,7 +1725,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
while (FileExists(path, timerId))
{
var parent = Path.GetDirectoryName(originalPath);
var parent = _fileSystem.GetDirectoryName(originalPath);
var name = Path.GetFileNameWithoutExtension(originalPath);
name += "-" + index.ToString(CultureInfo.InvariantCulture);
@ -1892,7 +1892,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return;
}
var imageSavePath = Path.Combine(Path.GetDirectoryName(recordingPath), imageSaveFilenameWithoutExtension);
var imageSavePath = Path.Combine(_fileSystem.GetDirectoryName(recordingPath), imageSaveFilenameWithoutExtension);
// preserve original image extension
imageSavePath = Path.ChangeExtension(imageSavePath, Path.GetExtension(image.Path));
@ -2545,7 +2545,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private void SaveEpgDataForChannel(string channelId, List<ProgramInfo> epgData)
{
var path = GetChannelEpgCachePath(channelId);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
lock (_epgLock)
{
_jsonSerializer.SerializeToFile(epgData, path);

View File

@ -108,7 +108,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
private Task RecordFromFile(MediaSourceInfo mediaSource, string inputFile, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{
_targetPath = targetFile;
_fileSystem.CreateDirectory(Path.GetDirectoryName(targetFile));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(targetFile));
var process = _processFactory.Create(new ProcessOptions
{
@ -134,7 +134,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_logger.Info(commandLineLogMessage);
var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "record-transcode-" + Guid.NewGuid() + ".txt");
_fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(logFilePath));
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
_logFileStream = _fileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true);

View File

@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
var file = _dataPath + ".json";
_fileSystem.CreateDirectory(Path.GetDirectoryName(file));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(file));
lock (_fileDataLock)
{

View File

@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}).ConfigureAwait(false);
_fileSystem.CreateDirectory(Path.GetDirectoryName(cacheFile));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFile));
using (var stream = _fileSystem.OpenRead(tempFile))
{

View File

@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.Logging
_logManager.Flush();
var path = Path.Combine(_appPaths.LogDirectoryPath, "unhandled_" + Guid.NewGuid() + ".txt");
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
var builder = LogHelper.GetLogMessage(ex);

View File

@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.MediaEncoder
var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, video.PlayableStreamFileNames);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
var container = video.Container;

View File

@ -136,7 +136,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
previouslyFailedImages.Add(key);
var parentPath = Path.GetDirectoryName(failHistoryPath);
var parentPath = _fileSystem.GetDirectoryName(failHistoryPath);
_fileSystem.CreateDirectory(parentPath);

View File

@ -193,7 +193,7 @@ namespace Emby.Server.Implementations.Security
}
var licenseFile = Filename;
_fileSystem.CreateDirectory(Path.GetDirectoryName(licenseFile));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(licenseFile));
lock (_fileLock)
{
_fileSystem.WriteAllLines(licenseFile, lines);

View File

@ -250,7 +250,7 @@ namespace Emby.Server.Implementations.Updates
}).ConfigureAwait(false);
_fileSystem.CreateDirectory(Path.GetDirectoryName(PackageCachePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(PackageCachePath));
_fileSystem.CopyFile(tempFile, PackageCachePath, true);
_lastPackageUpdateTime = DateTime.UtcNow;
@ -627,7 +627,7 @@ namespace Emby.Server.Implementations.Updates
// Success - move it to the real target
try
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(target));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(target));
_fileSystem.CopyFile(tempFile, target, true);
//If it is an archive - write out a version file so we know what it is
if (isArchive)

View File

@ -633,7 +633,7 @@ namespace MediaBrowser.Api
/// <param name="outputFilePath">The output file path.</param>
private void DeleteHlsPartialStreamFiles(string outputFilePath)
{
var directory = Path.GetDirectoryName(outputFilePath);
var directory = _fileSystem.GetDirectoryName(outputFilePath);
var name = Path.GetFileNameWithoutExtension(outputFilePath);
var filesToDelete = _fileSystem.GetFilePaths(directory)

View File

@ -278,7 +278,7 @@ namespace MediaBrowser.Api
public object Get(GetParentPath request)
{
var parent = Path.GetDirectoryName(request.Path);
var parent = _fileSystem.GetDirectoryName(request.Path);
if (string.IsNullOrEmpty(parent))
{

View File

@ -160,7 +160,7 @@ namespace MediaBrowser.Api.Images
private string GetThemeName(string path, string rootImagePath)
{
var parentName = Path.GetDirectoryName(path);
var parentName = _fileSystem.GetDirectoryName(path);
if (string.Equals(parentName, rootImagePath, StringComparison.OrdinalIgnoreCase))
{

View File

@ -278,7 +278,7 @@ namespace MediaBrowser.Api.Images
var fullCachePath = GetFullCachePath(urlHash + "." + ext);
_fileSystem.CreateDirectory(Path.GetDirectoryName(fullCachePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fullCachePath));
using (var stream = result.Content)
{
using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
@ -287,7 +287,7 @@ namespace MediaBrowser.Api.Images
}
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(pointerCachePath));
_fileSystem.WriteAllText(pointerCachePath, fullCachePath);
}

View File

@ -299,7 +299,7 @@ namespace MediaBrowser.Api
var fullCachePath = GetFullCachePath(urlHash + "." + ext);
_fileSystem.CreateDirectory(Path.GetDirectoryName(fullCachePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(fullCachePath));
using (var stream = result.Content)
{
using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
@ -308,7 +308,7 @@ namespace MediaBrowser.Api
}
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(pointerCachePath));
_fileSystem.WriteAllText(pointerCachePath, fullCachePath);
}

View File

@ -198,7 +198,7 @@ namespace MediaBrowser.Api.Playback
CancellationTokenSource cancellationTokenSource,
string workingDirectory = null)
{
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath));
await AcquireResources(state, cancellationTokenSource).ConfigureAwait(false);
@ -263,7 +263,7 @@ namespace MediaBrowser.Api.Playback
}
var logFilePath = Path.Combine(ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt");
FileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(logFilePath));
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
state.LogFileStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true);
@ -315,8 +315,6 @@ namespace MediaBrowser.Api.Playback
StartThrottler(state, transcodingJob);
}
ReportUsage(state);
return transcodingJob;
}
@ -910,123 +908,6 @@ namespace MediaBrowser.Api.Playback
}
}
private async void ReportUsage(StreamState state)
{
try
{
await ReportUsageInternal(state).ConfigureAwait(false);
}
catch
{
}
}
private Task ReportUsageInternal(StreamState state)
{
if (!ServerConfigurationManager.Configuration.EnableAnonymousUsageReporting)
{
return Task.FromResult(true);
}
if (!MediaEncoder.IsDefaultEncoderPath)
{
return Task.FromResult(true);
}
return Task.FromResult(true);
//var dict = new Dictionary<string, string>();
//var outputAudio = GetAudioEncoder(state);
//if (!string.IsNullOrWhiteSpace(outputAudio))
//{
// dict["outputAudio"] = outputAudio;
//}
//var outputVideo = GetVideoEncoder(state);
//if (!string.IsNullOrWhiteSpace(outputVideo))
//{
// dict["outputVideo"] = outputVideo;
//}
//if (ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputAudio ?? string.Empty, StringComparer.OrdinalIgnoreCase) &&
// ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
//{
// return Task.FromResult(true);
//}
//dict["id"] = AppHost.SystemId;
//dict["type"] = state.VideoRequest == null ? "Audio" : "Video";
//var audioStream = state.AudioStream;
//if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec))
//{
// dict["inputAudio"] = audioStream.Codec;
//}
//var videoStream = state.VideoStream;
//if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec))
//{
// dict["inputVideo"] = videoStream.Codec;
//}
//var cert = GetType().Assembly.GetModules().First().GetSignerCertificate();
//if (cert != null)
//{
// dict["assemblySig"] = cert.GetCertHashString();
// dict["certSubject"] = cert.Subject ?? string.Empty;
// dict["certIssuer"] = cert.Issuer ?? string.Empty;
//}
//else
//{
// return Task.FromResult(true);
//}
//if (state.SupportedAudioCodecs.Count > 0)
//{
// dict["supportedAudioCodecs"] = string.Join(",", state.SupportedAudioCodecs.ToArray());
//}
//var auth = AuthorizationContext.GetAuthorizationInfo(Request);
//dict["appName"] = auth.Client ?? string.Empty;
//dict["appVersion"] = auth.Version ?? string.Empty;
//dict["device"] = auth.Device ?? string.Empty;
//dict["deviceId"] = auth.DeviceId ?? string.Empty;
//dict["context"] = "streaming";
////Logger.Info(JsonSerializer.SerializeToString(dict));
//if (!ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputAudio ?? string.Empty, StringComparer.OrdinalIgnoreCase))
//{
// var list = ServerConfigurationManager.Configuration.CodecsUsed.ToList();
// list.Add(outputAudio);
// ServerConfigurationManager.Configuration.CodecsUsed = list.ToArray();
//}
//if (!ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
//{
// var list = ServerConfigurationManager.Configuration.CodecsUsed.ToList();
// list.Add(outputVideo);
// ServerConfigurationManager.Configuration.CodecsUsed = list.ToArray();
//}
//ServerConfigurationManager.SaveConfiguration();
////Logger.Info(JsonSerializer.SerializeToString(dict));
//var options = new HttpRequestOptions()
//{
// Url = "https://mb3admin.com/admin/service/transcoding/report",
// CancellationToken = CancellationToken.None,
// LogRequest = false,
// LogErrors = false,
// BufferContent = false
//};
//options.RequestContent = JsonSerializer.SerializeToString(dict);
//options.RequestContentType = "application/json";
//return HttpClient.Post(options);
}
/// <summary>
/// Adds the dlna headers.
/// </summary>

View File

@ -268,7 +268,7 @@ namespace MediaBrowser.Api.Playback.Hls
var useGenericSegmenter = true;
if (useGenericSegmenter)
{
var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request);
var outputTsArg = Path.Combine(FileSystem.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request);
var timeDeltaParam = String.Empty;

View File

@ -379,7 +379,7 @@ namespace MediaBrowser.Api.Playback.Hls
private static FileSystemMetadata GetLastTranscodingFile(string playlist, string segmentExtension, IFileSystem fileSystem)
{
var folder = Path.GetDirectoryName(playlist);
var folder = fileSystem.GetDirectoryName(playlist);
var filePrefix = Path.GetFileNameWithoutExtension(playlist) ?? string.Empty;
@ -416,7 +416,7 @@ namespace MediaBrowser.Api.Playback.Hls
private string GetSegmentPath(StreamState state, string playlist, int index)
{
var folder = Path.GetDirectoryName(playlist);
var folder = FileSystem.GetDirectoryName(playlist);
var filename = Path.GetFileNameWithoutExtension(playlist);
@ -926,7 +926,7 @@ namespace MediaBrowser.Api.Playback.Hls
if (useGenericSegmenter)
{
var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request);
var outputTsArg = Path.Combine(FileSystem.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state.Request);
var timeDeltaParam = String.Empty;

View File

@ -288,7 +288,7 @@ namespace MediaBrowser.Controller.Entities
return Path;
}
return System.IO.Path.GetDirectoryName(Path);
return FileSystem.GetDirectoryName(Path);
}
}
@ -1917,7 +1917,7 @@ namespace MediaBrowser.Controller.Entities
{
var allFiles = ImageInfos
.Where(i => i.IsLocalFile)
.Select(i => System.IO.Path.GetDirectoryName(i.Path))
.Select(i => FileSystem.GetDirectoryName(i.Path))
.Distinct(StringComparer.OrdinalIgnoreCase)
.SelectMany(directoryService.GetFilePaths)
.ToList();
@ -2092,7 +2092,7 @@ namespace MediaBrowser.Controller.Entities
var extensions = new[] { ".nfo", ".xml", ".srt" }.ToList();
extensions.AddRange(SupportedImageExtensionsList);
return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), extensions.ToArray(), false, false)
return FileSystem.GetFiles(FileSystem.GetDirectoryName(Path), extensions.ToArray(), false, false)
.Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase))
.ToList();
}

View File

@ -213,7 +213,7 @@ namespace MediaBrowser.Controller.Entities
.SelectMany(c => c.LinkedChildren)
.ToList();
var changed = !linkedChildren.SequenceEqual(LinkedChildren, new LinkedChildComparer());
var changed = !linkedChildren.SequenceEqual(LinkedChildren, new LinkedChildComparer(FileSystem));
LinkedChildren = linkedChildren;
@ -332,13 +332,13 @@ namespace MediaBrowser.Controller.Entities
.OfType<Folder>()
.ToList();
return PhysicalLocations.Where(i => !string.Equals(i, Path, StringComparison.OrdinalIgnoreCase)).SelectMany(i => GetPhysicalParents(i, rootChildren)).DistinctBy(i => i.Id);
return PhysicalLocations.Where(i => !FileSystem.AreEqual(i, Path)).SelectMany(i => GetPhysicalParents(i, rootChildren)).DistinctBy(i => i.Id);
}
private IEnumerable<Folder> GetPhysicalParents(string path, List<Folder> rootChildren)
{
var result = rootChildren
.Where(i => string.Equals(i.Path, path, StringComparison.OrdinalIgnoreCase))
.Where(i => FileSystem.AreEqual(i.Path, path))
.ToList();
if (result.Count == 0)

View File

@ -640,7 +640,7 @@ namespace MediaBrowser.Controller.Entities
return true;
}
path = System.IO.Path.GetDirectoryName(path);
path = FileSystem.GetDirectoryName(path);
}
return allLibraryPaths.Any(i => ContainsPath(i, originalPath));
@ -1206,11 +1206,17 @@ namespace MediaBrowser.Controller.Entities
return GetLinkedChildren();
}
var locations = user.RootFolder
.Children
if (LinkedChildren.Count == 0)
{
return new List<BaseItem>();
}
var allUserRootChildren = user.RootFolder.Children.OfType<Folder>().ToList();
var collectionFolderIds = allUserRootChildren
.OfType<CollectionFolder>()
.Where(i => i.IsVisible(user))
.SelectMany(i => i.PhysicalLocations)
.Select(i => i.Id)
.ToList();
return LinkedChildren
@ -1228,9 +1234,16 @@ namespace MediaBrowser.Controller.Entities
return null;
}
}
else if (childLocationType == LocationType.FileSystem && !locations.Any(l => FileSystem.ContainsSubPath(l, child.Path)))
else if (childLocationType == LocationType.FileSystem)
{
return null;
var itemCollectionFolderIds =
LibraryManager.GetCollectionFolders(child, allUserRootChildren)
.Select(f => f.Id).ToList();
if (!itemCollectionFolderIds.Any(collectionFolderIds.Contains))
{
return null;
}
}
}
@ -1323,7 +1336,7 @@ namespace MediaBrowser.Controller.Entities
}
else { newShortcutLinks = new List<LinkedChild>(); }
if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer()))
if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer(FileSystem)))
{
Logger.Info("Shortcut links have changed for {0}", Path);

View File

@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Entities
return new[] {
new FileSystemMetadata
{
FullName = System.IO.Path.GetDirectoryName(Path),
FullName = FileSystem.GetDirectoryName(Path),
IsDirectory = true
}
};

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Controller.Entities
@ -40,11 +41,18 @@ namespace MediaBrowser.Controller.Entities
public class LinkedChildComparer : IEqualityComparer<LinkedChild>
{
private readonly IFileSystem _fileSystem;
public LinkedChildComparer(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
public bool Equals(LinkedChild x, LinkedChild y)
{
if (x.Type == y.Type)
{
return string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase);
return _fileSystem.AreEqual(x.Path, y.Path);
}
return false;
}

View File

@ -125,7 +125,7 @@ namespace MediaBrowser.Controller.Entities.TV
return series.Path;
}
return System.IO.Path.GetDirectoryName(Path);
return FileSystem.GetDirectoryName(Path);
}
}

View File

@ -311,7 +311,7 @@ namespace MediaBrowser.Controller.Entities
{
if (IsStacked)
{
return System.IO.Path.GetDirectoryName(Path);
return FileSystem.GetDirectoryName(Path);
}
if (!IsPlaceHolder)

View File

@ -456,6 +456,8 @@ namespace MediaBrowser.Controller.Library
/// <returns>IEnumerable&lt;Folder&gt;.</returns>
List<Folder> GetCollectionFolders(BaseItem item);
List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren);
LibraryOptions GetLibraryOptions(BaseItem item);
/// <summary>

View File

@ -114,7 +114,7 @@ namespace MediaBrowser.Controller.Library
return false;
}
var parentDir = System.IO.Path.GetDirectoryName(Path) ?? string.Empty;
var parentDir = BaseItem.FileSystem.GetDirectoryName(Path) ?? string.Empty;
return parentDir.Length > _appPaths.RootFolderPath.Length
&& parentDir.StartsWith(_appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase);
@ -130,7 +130,7 @@ namespace MediaBrowser.Controller.Library
{
get
{
return IsDirectory && string.Equals(Path, _appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase);
return IsDirectory && BaseItem.FileSystem.AreEqual(Path, _appPaths.RootFolderPath);
}
}
@ -300,7 +300,7 @@ namespace MediaBrowser.Controller.Library
if (args != null)
{
if (args.Path == null && Path == null) return true;
return args.Path != null && args.Path.Equals(Path, StringComparison.OrdinalIgnoreCase);
return args.Path != null && BaseItem.FileSystem.AreEqual(args.Path, Path);
}
return false;
}

View File

@ -126,7 +126,6 @@ namespace MediaBrowser.Controller.MediaEncoding
Task UpdateEncoderPath(string path, string pathType);
bool SupportsEncoder(string encoder);
bool IsDefaultEncoderPath { get; }
void SetLogFilename(string name);
void ClearLogFilename();

View File

@ -63,11 +63,11 @@ namespace MediaBrowser.Controller.Providers
//_logger.Debug("Getting files for " + path);
entries = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);
try
{
// using EnumerateFileSystemInfos doesn't handle reparse points (symlinks)
var list = _fileSystem.GetFileSystemEntries(path)
var list = _fileSystem.GetFileSystemEntries(path)
.ToList();
// Seeing dupes on some users file system for some reason
@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Providers
{
}
//var group = entries.ToLookup(i => Path.GetDirectoryName(i.FullName)).ToList();
//var group = entries.ToLookup(i => _fileSystem.GetDirectoryName(i.FullName)).ToList();
_cache.TryAdd(path, entries);
}

View File

@ -38,7 +38,7 @@ namespace MediaBrowser.LocalMetadata.Images
public List<LocalImageInfo> GetImages(IHasImages item, IDirectoryService directoryService)
{
var parentPath = Path.GetDirectoryName(item.Path);
var parentPath = _fileSystem.GetDirectoryName(item.Path);
var parentPathFiles = directoryService.GetFileSystemEntries(parentPath)
.ToList();

View File

@ -84,7 +84,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
// even though it's actually using the metadata folder.
filename = Path.GetFileName(filename);
var parentFolder = Path.GetDirectoryName(_xmlPath);
var parentFolder = _fileSystem.GetDirectoryName(_xmlPath);
filename = Path.Combine(parentFolder, filename);
var file = _fileSystem.GetFileInfo(filename);

View File

@ -39,7 +39,7 @@ namespace MediaBrowser.LocalMetadata.Providers
protected override FileSystemMetadata GetXmlFile(ItemInfo info, IDirectoryService directoryService)
{
var metadataPath = Path.GetDirectoryName(info.Path);
var metadataPath = FileSystem.GetDirectoryName(info.Path);
metadataPath = Path.Combine(metadataPath, "metadata");
var metadataFile = Path.Combine(metadataPath, Path.ChangeExtension(Path.GetFileName(info.Path), ".xml"));

View File

@ -35,7 +35,7 @@ namespace MediaBrowser.LocalMetadata.Providers
var specificFile = Path.ChangeExtension(info.Path, ".xml");
var file = FileSystem.GetFileInfo(specificFile);
return info.IsInMixedFolder || file.Exists ? file : FileSystem.GetFileInfo(Path.Combine(Path.GetDirectoryName(info.Path), "game.xml"));
return info.IsInMixedFolder || file.Exists ? file : FileSystem.GetFileInfo(Path.Combine(FileSystem.GetDirectoryName(info.Path), "game.xml"));
}
}
}

View File

@ -39,7 +39,7 @@ namespace MediaBrowser.LocalMetadata.Providers
{
var fileInfo = fileSystem.GetFileSystemInfo(info.Path);
var directoryInfo = fileInfo.IsDirectory ? fileInfo : fileSystem.GetDirectoryInfo(Path.GetDirectoryName(info.Path));
var directoryInfo = fileInfo.IsDirectory ? fileInfo : fileSystem.GetDirectoryInfo(fileSystem.GetDirectoryName(info.Path));
var directoryPath = directoryInfo.FullName;

View File

@ -209,7 +209,7 @@ namespace MediaBrowser.LocalMetadata.Savers
private void SaveToFile(Stream stream, string path)
{
FileSystem.CreateDirectory(Path.GetDirectoryName(path));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path));
var file = FileSystem.GetFileInfo(path);

View File

@ -70,7 +70,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
.CreateJob(options, EncodingHelper, IsVideoEncoder, progress, cancellationToken).ConfigureAwait(false);
encodingJob.OutputFilePath = GetOutputFilePath(encodingJob);
FileSystem.CreateDirectory(Path.GetDirectoryName(encodingJob.OutputFilePath));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(encodingJob.OutputFilePath));
encodingJob.ReadInputAtNativeFramerate = options.ReadInputAtNativeFramerate;
@ -108,7 +108,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
Logger.Info(commandLineLogMessage);
var logFilePath = Path.Combine(ConfigurationManager.CommonApplicationPaths.LogDirectoryPath, "transcode-" + Guid.NewGuid() + ".txt");
FileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(logFilePath));
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
encodingJob.LogFileStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true);

View File

@ -45,6 +45,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
/// <returns>System.String.</returns>
private static string GetFileInputArgument(string path)
{
if (path.IndexOf("://") != -1)
{
return string.Format("\"{0}\"", path);
}
// Quotes are valid path characters in linux and they need to be escaped here with a leading \
path = NormalizePath(path);

View File

@ -187,18 +187,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
}
public bool IsDefaultEncoderPath
{
get
{
var path = FFMpegPath;
var parentPath = Path.Combine(ConfigurationManager.ApplicationPaths.ProgramDataPath, "ffmpeg", "20160410");
return FileSystem.ContainsSubPath(parentPath, path);
}
}
private bool IsSystemInstalledPath(string path)
{
if (path.IndexOf("/", StringComparison.Ordinal) == -1 && path.IndexOf("\\", StringComparison.Ordinal) == -1)
@ -222,12 +210,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
if (EnableEncoderFontFile)
{
var directory = Path.GetDirectoryName(FFMpegPath);
var directory = FileSystem.GetDirectoryName(FFMpegPath);
if (!string.IsNullOrWhiteSpace(directory) && FileSystem.ContainsSubPath(ConfigurationManager.ApplicationPaths.ProgramDataPath, directory))
{
await new FontConfigLoader(_httpClient, ConfigurationManager.ApplicationPaths, _logger, _zipClient,
FileSystem).DownloadFonts(directory).ConfigureAwait(false);
await new FontConfigLoader(_httpClient, ConfigurationManager.ApplicationPaths, _logger, _zipClient, FileSystem).DownloadFonts(directory).ConfigureAwait(false);
}
}
}
@ -428,7 +415,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
private string GetProbePathFromEncoderPath(string appPath)
{
return FileSystem.GetFilePaths(Path.GetDirectoryName(appPath))
return FileSystem.GetFilePaths(FileSystem.GetDirectoryName(appPath))
.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffprobe", StringComparison.OrdinalIgnoreCase));
}
@ -717,7 +704,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
var tempExtractPath = Path.Combine(ConfigurationManager.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".jpg");
FileSystem.CreateDirectory(Path.GetDirectoryName(tempExtractPath));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(tempExtractPath));
// apply some filters to thumbnail extracted below (below) crop any black lines that we made and get the correct ar then scale to width 600.
// This filter chain may have adverse effects on recorded tv thumbnails if ar changes during presentation ex. commercials @ diff ar

View File

@ -412,7 +412,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
throw new ArgumentNullException("outputPath");
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(outputPath));
var encodingParam = await GetSubtitleFileCharacterSet(inputPath, language, inputProtocol, cancellationToken).ConfigureAwait(false);
@ -546,7 +546,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
throw new ArgumentNullException("outputPath");
}
_fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(outputPath));
var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s {2} \"{3}\"", inputPath,
subtitleStreamIndex, outputCodec, outputPath);

View File

@ -146,6 +146,8 @@ namespace MediaBrowser.Model.IO
/// <returns>System.String.</returns>
string NormalizePath(string path);
string GetDirectoryName(string path);
/// <summary>
/// Gets the file name without extension.
/// </summary>

View File

@ -158,7 +158,7 @@ namespace MediaBrowser.Providers.BoxSets
var dataFilePath = GetDataFilePath(_config.ApplicationPaths, tmdbId, preferredMetadataLanguage);
_fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath));
_json.SerializeToFile(mainResult, dataFilePath);
}

View File

@ -35,7 +35,7 @@ namespace MediaBrowser.Providers.ImagesByName
}).ConfigureAwait(false);
fileSystem.CreateDirectory(Path.GetDirectoryName(file));
fileSystem.CreateDirectory(fileSystem.GetDirectoryName(file));
try
{

View File

@ -238,7 +238,7 @@ namespace MediaBrowser.Providers.Manager
{
_logger.Debug("Saving image to {0}", path);
var parentFolder = Path.GetDirectoryName(path);
var parentFolder = _fileSystem.GetDirectoryName(path);
await _imageSaveSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
@ -247,7 +247,7 @@ namespace MediaBrowser.Providers.Manager
_libraryMonitor.ReportFileSystemChangeBeginning(path);
_libraryMonitor.ReportFileSystemChangeBeginning(parentFolder);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
// If the file is currently hidden we'll have to remove that or the save will fail
var file = _fileSystem.GetFileInfo(path);
@ -449,7 +449,7 @@ namespace MediaBrowser.Providers.Manager
{
if (type == ImageType.Primary && item is Episode)
{
path = Path.Combine(Path.GetDirectoryName(item.Path), "metadata", filename + extension);
path = Path.Combine(_fileSystem.GetDirectoryName(item.Path), "metadata", filename + extension);
}
else if (item.DetectIsInMixedFolder())
@ -581,7 +581,7 @@ namespace MediaBrowser.Providers.Manager
if (item is Episode)
{
var seasonFolder = Path.GetDirectoryName(item.Path);
var seasonFolder = _fileSystem.GetDirectoryName(item.Path);
var imageFilename = _fileSystem.GetFileNameWithoutExtension(item.Path) + "-thumb" + extension;
@ -629,7 +629,7 @@ namespace MediaBrowser.Providers.Manager
{
imageFilename = "poster";
}
var folder = Path.GetDirectoryName(item.Path);
var folder = _fileSystem.GetDirectoryName(item.Path);
return Path.Combine(folder, _fileSystem.GetFileNameWithoutExtension(item.Path) + "-" + imageFilename + extension);
}

View File

@ -62,7 +62,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (!_fileSystem.FileExists(path))
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
var imageStream = imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("front", StringComparison.OrdinalIgnoreCase) != -1) ??
imageStreams.FirstOrDefault(i => (i.Comment ?? string.Empty).IndexOf("cover", StringComparison.OrdinalIgnoreCase) != -1) ??

View File

@ -78,7 +78,7 @@ namespace MediaBrowser.Providers.MediaInfo
}, cancellationToken).ConfigureAwait(false);
//Directory.CreateDirectory(Path.GetDirectoryName(cachePath));
//Directory.CreateDirectory(_fileSystem.GetDirectoryName(cachePath));
//_json.SerializeToFile(result, cachePath);
return result;

View File

@ -150,7 +150,7 @@ namespace MediaBrowser.Providers.MediaInfo
}, cancellationToken).ConfigureAwait(false);
//Directory.CreateDirectory(Path.GetDirectoryName(cachePath));
//Directory.CreateDirectory(_fileSystem.GetDirectoryName(cachePath));
//_json.SerializeToFile(result, cachePath);
return result;

View File

@ -277,7 +277,7 @@ namespace MediaBrowser.Providers.Movies
var path = GetFanartJsonPath(id);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
try
{

View File

@ -94,7 +94,7 @@ namespace MediaBrowser.Providers.Movies
tmdbId = movieInfo.id.ToString(_usCulture);
dataFilePath = MovieDbProvider.Current.GetDataFilePath(tmdbId, language);
_fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath));
_jsonSerializer.SerializeToFile(movieInfo, dataFilePath);
}
}

View File

@ -208,7 +208,7 @@ namespace MediaBrowser.Providers.Movies
var dataFilePath = GetDataFilePath(id, preferredMetadataLanguage);
_fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath));
_jsonSerializer.SerializeToFile(mainResult, dataFilePath);
}

View File

@ -159,7 +159,7 @@ namespace MediaBrowser.Providers.Music
var path = GetAlbumInfoPath(_config.ApplicationPaths, musicBrainzReleaseGroupId);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
using (var response = await _httpClient.Get(new HttpRequestOptions
{

View File

@ -155,7 +155,7 @@ namespace MediaBrowser.Providers.Music
}).ConfigureAwait(false))
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
using (var xmlFileStream = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
{

View File

@ -247,7 +247,7 @@ namespace MediaBrowser.Providers.Music
var jsonPath = GetArtistJsonPath(_config.ApplicationPaths, musicBrainzId);
_fileSystem.CreateDirectory(Path.GetDirectoryName(jsonPath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(jsonPath));
try
{

View File

@ -298,7 +298,7 @@ namespace MediaBrowser.Providers.Omdb
using (var stream = await GetOmdbResponse(_httpClient, url, cancellationToken).ConfigureAwait(false))
{
var rootObject = _jsonSerializer.DeserializeFromStream<RootObject>(stream);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
_jsonSerializer.SerializeToFile(rootObject, path);
}
@ -333,7 +333,7 @@ namespace MediaBrowser.Providers.Omdb
using (var stream = await GetOmdbResponse(_httpClient, url, cancellationToken).ConfigureAwait(false))
{
var rootObject = _jsonSerializer.DeserializeFromStream<SeasonRootObject>(stream);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
_jsonSerializer.SerializeToFile(rootObject, path);
}

View File

@ -250,7 +250,7 @@ namespace MediaBrowser.Providers.People
}).ConfigureAwait(false))
{
_fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath));
using (var fs = _fileSystem.GetFileStream(dataFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
{

View File

@ -115,7 +115,7 @@ namespace MediaBrowser.Providers.Subtitles
using (var stream = response.Stream)
{
var savePath = Path.Combine(Path.GetDirectoryName(video.Path),
var savePath = Path.Combine(_fileSystem.GetDirectoryName(video.Path),
_fileSystem.GetFileNameWithoutExtension(video.Path) + "." + response.Language.ToLower());
if (response.IsForced)

View File

@ -312,7 +312,7 @@ namespace MediaBrowser.Providers.TV
var path = GetFanartJsonPath(tvdbId);
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path));
try
{

View File

@ -106,7 +106,7 @@ namespace MediaBrowser.Providers.TV
var dataFilePath = GetDataFilePath(id, seasonNumber, episodeNumber, preferredMetadataLanguage);
_fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath));
_jsonSerializer.SerializeToFile(mainResult, dataFilePath);
}

View File

@ -190,7 +190,7 @@ namespace MediaBrowser.Providers.TV
var dataFilePath = GetDataFilePath(id, seasonNumber, preferredMetadataLanguage);
_fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath));
_jsonSerializer.SerializeToFile(mainResult, dataFilePath);
}

View File

@ -198,7 +198,7 @@ namespace MediaBrowser.Providers.TV
tmdbId = seriesInfo.id.ToString(_usCulture);
dataFilePath = GetDataFilePath(tmdbId, language);
_fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath));
_jsonSerializer.SerializeToFile(seriesInfo, dataFilePath);
await EnsureSeriesInfo(tmdbId, language, cancellationToken).ConfigureAwait(false);
@ -330,7 +330,7 @@ namespace MediaBrowser.Providers.TV
var dataFilePath = GetDataFilePath(id, preferredMetadataLanguage);
_fileSystem.CreateDirectory(Path.GetDirectoryName(dataFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(dataFilePath));
_jsonSerializer.SerializeToFile(mainResult, dataFilePath);
}

View File

@ -226,7 +226,7 @@ namespace MediaBrowser.Providers.TV
if (searchInfo.IndexNumber.HasValue)
{
var files = GetEpisodeXmlFiles(searchInfo.ParentIndexNumber, searchInfo.IndexNumber, searchInfo.IndexNumberEnd, Path.GetDirectoryName(xmlFile));
var files = GetEpisodeXmlFiles(searchInfo.ParentIndexNumber, searchInfo.IndexNumber, searchInfo.IndexNumberEnd, _fileSystem.GetDirectoryName(xmlFile));
list = files.Select(GetXmlReader).ToList();
}

View File

@ -98,8 +98,8 @@ namespace MediaBrowser.WebDashboard.Api
}
path = GetDashboardResourcePath(path);
var parent = Path.GetDirectoryName(path);
var parent = _fileSystem.GetDirectoryName(path);
return string.Equals(_basePath, parent, StringComparison.OrdinalIgnoreCase) ||
string.Equals(Path.Combine(_basePath, "voice"), parent, StringComparison.OrdinalIgnoreCase);
}

View File

@ -211,7 +211,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
private void SaveToFile(Stream stream, string path)
{
FileSystem.CreateDirectory(Path.GetDirectoryName(path));
FileSystem.CreateDirectory(FileSystem.GetDirectoryName(path));
var file = FileSystem.GetFileInfo(path);

View File

@ -1,3 +1,3 @@
using System.Reflection;
[assembly: AssemblyVersion("3.2.13.12")]
[assembly: AssemblyVersion("3.2.13.13")]