diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations')
31 files changed, 77 insertions, 286 deletions
diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index f670176e6..b02b2996f 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -318,7 +318,7 @@ namespace MediaBrowser.Server.Implementations.Channels try { - var files = new DirectoryInfo(parentPath).EnumerateFiles("*", SearchOption.TopDirectoryOnly); + var files = _fileSystem.GetFiles(parentPath); if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) { @@ -411,7 +411,7 @@ namespace MediaBrowser.Server.Implementations.Channels { _logger.Debug("Creating directory {0}", path); - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); fileInfo = new DirectoryInfo(path); if (!fileInfo.Exists) @@ -1082,7 +1082,7 @@ namespace MediaBrowser.Server.Implementations.Channels { try { - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); _jsonSerializer.SerializeToFile(result, path); } @@ -1462,7 +1462,7 @@ namespace MediaBrowser.Server.Implementations.Channels options.RequestHeaders[header.Key] = header.Value; } - Directory.CreateDirectory(Path.GetDirectoryName(destination)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(destination)); // Determine output extension var response = await _httpClient.GetTempFileResponse(options).ConfigureAwait(false); @@ -1500,7 +1500,7 @@ namespace MediaBrowser.Server.Implementations.Channels throw new ApplicationException("Unexpected response type encountered: " + response.ContentType); } - File.Copy(response.TempFilePath, destination, true); + _fileSystem.CopyFile(response.TempFilePath, destination, true); try { diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index 04f82db6f..3932e4073 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -70,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.Collections try { - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); var collection = new BoxSet { diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionsDynamicFolder.cs b/MediaBrowser.Server.Implementations/Collections/CollectionsDynamicFolder.cs index 915a27c11..959c47947 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionsDynamicFolder.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionsDynamicFolder.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Server.Implementations.Collections { var path = Path.Combine(_appPaths.DataPath, "collections"); - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); return new ManualCollectionsFolder { diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index bf199503b..54e53d7c4 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -198,7 +198,7 @@ namespace MediaBrowser.Server.Implementations.Configuration && !string.Equals(Configuration.ItemsByNamePath ?? string.Empty, newPath)) { // Validate - if (!Directory.Exists(newPath)) + if (!_fileSystem.DirectoryExists(newPath)) { throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); } @@ -218,7 +218,7 @@ namespace MediaBrowser.Server.Implementations.Configuration && !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath)) { // Validate - if (!Directory.Exists(newPath)) + if (!_fileSystem.DirectoryExists(newPath)) { throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); } diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs index 8a659fb65..86feaee6d 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs @@ -90,8 +90,8 @@ namespace MediaBrowser.Server.Implementations.Connect try { - Directory.CreateDirectory(Path.GetDirectoryName(path)); - File.WriteAllText(path, address, Encoding.UTF8); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.WriteAllText(path, address, Encoding.UTF8); } catch (Exception ex) { @@ -105,7 +105,7 @@ namespace MediaBrowser.Server.Implementations.Connect try { - var endpoint = File.ReadAllText(path, Encoding.UTF8); + var endpoint = _fileSystem.ReadAllText(path, Encoding.UTF8); if (IsValid(endpoint)) { diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 7cd96c5f3..f9aa8814d 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -315,7 +315,7 @@ namespace MediaBrowser.Server.Implementations.Connect try { - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); var json = _json.SerializeToString(_data); @@ -323,7 +323,7 @@ namespace MediaBrowser.Server.Implementations.Connect lock (_dataFileLock) { - File.WriteAllText(path, encrypted, Encoding.UTF8); + _fileSystem.WriteAllText(path, encrypted, Encoding.UTF8); } } catch (Exception ex) @@ -340,7 +340,7 @@ namespace MediaBrowser.Server.Implementations.Connect { lock (_dataFileLock) { - var encrypted = File.ReadAllText(path, Encoding.UTF8); + var encrypted = _fileSystem.ReadAllText(path, Encoding.UTF8); var json = _encryption.DecryptString(encrypted); diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs index 566f4c5f4..d0058b5ff 100644 --- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs +++ b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -61,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.Devices { var path = Path.Combine(_appPaths.DataPath, "camerauploads"); - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); return new CameraUploadsFolder { diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs index 0173f2784..a6a8b3a7a 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs @@ -157,7 +157,7 @@ namespace MediaBrowser.Server.Implementations.Devices _libraryMonitor.ReportFileSystemChangeBeginning(path); - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); try { diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs index 6d324b1ab..b8262d05f 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceRepository.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.Devices public Task SaveDevice(DeviceInfo device) { var path = Path.Combine(GetDevicePath(device.Id), "device.json"); - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_syncLock) { @@ -178,7 +178,7 @@ namespace MediaBrowser.Server.Implementations.Devices public void AddCameraUpload(string deviceId, LocalFileInfo file) { var path = Path.Combine(GetDevicePath(deviceId), "camerauploads.json"); - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_syncLock) { diff --git a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs index d5b7f5b36..932e94b2a 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs @@ -60,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications { var dataPath = Path.Combine(_appPaths.DataPath, "remotenotifications.json"); - var lastRunTime = File.Exists(dataPath) ? _fileSystem.GetLastWriteTimeUtc(dataPath) : DateTime.MinValue; + var lastRunTime = _fileSystem.FileExists(dataPath) ? _fileSystem.GetLastWriteTimeUtc(dataPath) : DateTime.MinValue; try { @@ -88,7 +88,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications { var notifications = _json.DeserializeFromStream<RemoteNotification[]>(stream); - File.WriteAllText(dataPath, string.Empty); + _fileSystem.WriteAllText(dataPath, string.Empty); await CreateNotifications(notifications, lastRunTime).ConfigureAwait(false); } diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index 06b72e4ef..0389980e2 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -182,7 +182,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization _logger.Info("Sorting file {0} to new path {1}", sourcePath, newPath); result.TargetPath = newPath; - var fileExists = File.Exists(result.TargetPath); + var fileExists = _fileSystem.FileExists(result.TargetPath); var otherDuplicatePaths = GetOtherDuplicatePaths(result.TargetPath, series, seasonNumber, episodeNumber, endingEpiosdeNumber); if (!overwriteExisting) @@ -272,7 +272,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization var destination = Path.Combine(directory, filename); - File.Move(file, destination); + _fileSystem.MoveFile(file, destination); } } } @@ -332,19 +332,19 @@ namespace MediaBrowser.Server.Implementations.FileOrganization { _libraryMonitor.ReportFileSystemChangeBeginning(result.TargetPath); - Directory.CreateDirectory(Path.GetDirectoryName(result.TargetPath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(result.TargetPath)); - var targetAlreadyExists = File.Exists(result.TargetPath); + var targetAlreadyExists = _fileSystem.FileExists(result.TargetPath); try { if (targetAlreadyExists || options.CopyOriginalFile) { - File.Copy(result.OriginalPath, result.TargetPath, true); + _fileSystem.CopyFile(result.OriginalPath, result.TargetPath, true); } else { - File.Move(result.OriginalPath, result.TargetPath); + _fileSystem.MoveFile(result.OriginalPath, result.TargetPath); } result.Status = FileSortingStatus.Success; diff --git a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs index 0caa8c26e..3e7a1d59e 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs @@ -132,8 +132,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization { try { - return new DirectoryInfo(path) - .EnumerateFiles("*", SearchOption.AllDirectories) + return _fileSystem.GetFiles(path, true) .ToList(); } catch (IOException ex) @@ -151,8 +150,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization /// <param name="extensions">The extensions.</param> private void DeleteLeftOverFiles(string path, IEnumerable<string> extensions) { - var eligibleFiles = new DirectoryInfo(path) - .EnumerateFiles("*", SearchOption.AllDirectories) + var eligibleFiles = _fileSystem.GetFiles(path, true) .Where(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) .ToList(); @@ -189,7 +187,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization try { _logger.Debug("Deleting empty directory {0}", path); - Directory.Delete(path); + _fileSystem.DeleteDirectory(path); } catch (UnauthorizedAccessException) { } catch (DirectoryNotFoundException) { } diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs index 5bd26ce18..cb9d5a09f 100644 --- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs +++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs @@ -645,7 +645,7 @@ namespace MediaBrowser.Server.Implementations.IO if (item != null) { // If the item has been deleted find the first valid parent that still exists - while (!Directory.Exists(item.Path) && !File.Exists(item.Path)) + while (!_fileSystem.DirectoryExists(item.Path) && !_fileSystem.FileExists(item.Path)) { item = item.Parent; diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index c8f472536..c3ef5366d 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -395,12 +395,12 @@ namespace MediaBrowser.Server.Implementations.Library { foreach (var path in item.GetDeletePaths().ToList()) { - if (Directory.Exists(path)) + if (_fileSystem.DirectoryExists(path)) { _logger.Debug("Deleting path {0}", path); _fileSystem.DeleteDirectory(path, true); } - else if (File.Exists(path)) + else if (_fileSystem.FileExists(path)) { _logger.Debug("Deleting path {0}", path); _fileSystem.DeleteFile(path); @@ -691,7 +691,7 @@ namespace MediaBrowser.Server.Implementations.Library { var rootFolderPath = ConfigurationManager.ApplicationPaths.RootFolderPath; - Directory.CreateDirectory(rootFolderPath); + _fileSystem.CreateDirectory(rootFolderPath); var rootFolder = GetItemById(GetNewItemId(rootFolderPath, typeof(AggregateFolder))) as AggregateFolder ?? (AggregateFolder)ResolvePath(new DirectoryInfo(rootFolderPath)); @@ -742,7 +742,7 @@ namespace MediaBrowser.Server.Implementations.Library { var userRootPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; - Directory.CreateDirectory(userRootPath); + _fileSystem.CreateDirectory(userRootPath); var tmpItem = GetItemById(GetNewItemId(userRootPath, typeof(UserRootFolder))) as UserRootFolder; @@ -1007,7 +1007,7 @@ namespace MediaBrowser.Server.Implementations.Library public Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress) { // Ensure the location is available. - Directory.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath); + _fileSystem.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath); return new PeopleValidator(this, _logger, ConfigurationManager).ValidatePeople(cancellationToken, progress); } @@ -1671,7 +1671,7 @@ namespace MediaBrowser.Server.Implementations.Library if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase)) { - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); item = new UserView { @@ -1758,7 +1758,7 @@ namespace MediaBrowser.Server.Implementations.Library if (item == null) { - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); item = new UserView { @@ -1828,7 +1828,7 @@ namespace MediaBrowser.Server.Implementations.Library if (item == null) { - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); item = new UserView { diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index 63067bf5a..d967f8b11 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -170,7 +170,7 @@ namespace MediaBrowser.Server.Implementations.Library if (source.Protocol == MediaProtocol.File) { // TODO: Path substitution - if (!File.Exists(source.Path)) + if (!_fileSystem.FileExists(source.Path)) { source.SupportsDirectStream = false; } diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 5012f2479..83dcc7fc1 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -745,7 +745,7 @@ namespace MediaBrowser.Server.Implementations.Library text.AppendLine(string.Empty); text.AppendLine("The pin code will expire at " + expiration.ToLocalTime().ToShortDateString() + " " + expiration.ToLocalTime().ToShortTimeString()); - File.WriteAllText(path, text.ToString(), Encoding.UTF8); + _fileSystem.WriteAllText(path, text.ToString(), Encoding.UTF8); var result = new PasswordPinCreationResult { @@ -919,7 +919,7 @@ namespace MediaBrowser.Server.Implementations.Library var path = GetPolifyFilePath(user); - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_policySyncLock) { @@ -1006,7 +1006,7 @@ namespace MediaBrowser.Server.Implementations.Library config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json); } - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_configSyncLock) { diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index fb5824805..f2d9ca21d 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -239,7 +239,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV try { - File.Delete(remove.Path); + _filesystem.DeleteFile(remove.Path); } catch (DirectoryNotFoundException) { @@ -643,7 +643,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV var recordingFileName = _fileSystem.GetValidFilename(RecordingHelper.GetRecordingName(timer, info)) + ".ts"; recordPath = Path.Combine(recordPath, recordingFileName); - Directory.CreateDirectory(Path.GetDirectoryName(recordPath)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath)); var recording = _recordingProvider.GetAll().FirstOrDefault(x => string.Equals(x.ProgramId, info.Id, StringComparison.OrdinalIgnoreCase)); @@ -697,7 +697,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV _logger.Info("Writing file to path: " + recordPath); using (var response = await _httpClient.SendAsync(httpRequestOptions, "GET")) { - using (var output = File.Open(recordPath, FileMode.Create, FileAccess.Write, FileShare.Read)) + using (var output = _fileSystem.GetFileStream(recordPath, FileMode.Create, FileAccess.Write, FileShare.Read)) { await response.Content.CopyToAsync(output, StreamDefaults.DefaultCopyToBufferSize, linkedToken); } @@ -858,7 +858,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV private void SaveEpgDataForChannel(string channelId, List<ProgramInfo> epgData) { var path = GetChannelEpgCachePath(channelId); - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); lock (_epgLock) { _jsonSerializer.SerializeToFile(epgData, path); diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 75dec5f97..9769148a2 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV private void UpdateList(List<T> newList) { var file = _dataPath + ".json"; - Directory.CreateDirectory(Path.GetDirectoryName(file)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(file)); lock (_fileDataLock) { diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 3783e4b08..5a4d34437 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -119,7 +119,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts public async Task Validate(TunerHostInfo info) { - if (!File.Exists(info.Url)) + if (!_fileSystem.FileExists(info.Url)) { throw new FileNotFoundException(); } diff --git a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs b/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs index 8c893c8d1..4842fbb24 100644 --- a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs +++ b/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs @@ -58,7 +58,7 @@ namespace MediaBrowser.Server.Implementations.Localization var localizationPath = LocalizationPath; - Directory.CreateDirectory(localizationPath); + _fileSystem.CreateDirectory(localizationPath); var existingFiles = Directory.EnumerateFiles(localizationPath, "ratings-*.txt", SearchOption.TopDirectoryOnly) .Select(Path.GetFileName) @@ -212,7 +212,7 @@ namespace MediaBrowser.Server.Implementations.Localization /// <returns>Dictionary{System.StringParentalRating}.</returns> private void LoadRatings(string file) { - var dict = File.ReadAllLines(file).Select(i => + var dict = _fileSystem.ReadAllLines(file).Select(i => { if (!string.IsNullOrWhiteSpace(i)) { diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 11dd7c28d..b6e0ade5b 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -11,10 +11,10 @@ <AssemblyName>MediaBrowser.Server.Implementations</AssemblyName> <FileAlignment>512</FileAlignment> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> - <ProductVersion>10.0.0</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <RestorePackages>true</RestorePackages> + <ReleaseVersion> + </ReleaseVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -24,7 +24,6 @@ <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>none</DebugType> @@ -33,7 +32,6 @@ <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release Mono|AnyCPU' "> <DebugType>none</DebugType> @@ -42,35 +40,17 @@ <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> </PropertyGroup> <ItemGroup> <Reference Include="Interfaces.IO"> <HintPath>..\packages\Interfaces.IO.1.0.0.5\lib\portable-net45+sl4+wp71+win8+wpa81\Interfaces.IO.dll</HintPath> </Reference> - <Reference Include="MediaBrowser.Naming, Version=1.0.5614.25103, Culture=neutral, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\MediaBrowser.Naming.1.0.0.37\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath> - </Reference> - <Reference Include="Mono.Nat, Version=1.2.24.0, Culture=neutral, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\Mono.Nat.1.2.24.0\lib\net40\Mono.Nat.dll</HintPath> - </Reference> - <Reference Include="MoreLinq, Version=1.1.18418.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\morelinq.1.1.1\lib\net35\MoreLinq.dll</HintPath> - </Reference> <Reference Include="Patterns.Logging"> <HintPath>..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll</HintPath> - <Private>True</Private> </Reference> <Reference Include="ServiceStack.Api.Swagger"> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll</HintPath> </Reference> - <Reference Include="SocketHttpListener, Version=1.0.5634.16042, Culture=neutral, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\SocketHttpListener.1.0.0.7\lib\net45\SocketHttpListener.dll</HintPath> - </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Data.SQLite"> @@ -100,6 +80,18 @@ <Reference Include="UniversalDetector"> <HintPath>..\ThirdParty\UniversalDetector\UniversalDetector.dll</HintPath> </Reference> + <Reference Include="MediaBrowser.Naming"> + <HintPath>..\packages\MediaBrowser.Naming.1.0.0.37\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath> + </Reference> + <Reference Include="Mono.Nat"> + <HintPath>..\packages\Mono.Nat.1.2.24.0\lib\net40\Mono.Nat.dll</HintPath> + </Reference> + <Reference Include="MoreLinq"> + <HintPath>..\packages\morelinq.1.1.1\lib\net35\MoreLinq.dll</HintPath> + </Reference> + <Reference Include="SocketHttpListener"> + <HintPath>..\packages\SocketHttpListener.1.0.0.7\lib\net45\SocketHttpListener.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="..\SharedVersion.cs"> @@ -334,7 +326,6 @@ <Compile Include="Sync\SyncRepository.cs" /> <Compile Include="Sync\SyncConvertScheduledTask.cs" /> <Compile Include="Sync\TargetDataProvider.cs" /> - <Compile Include="Themes\AppThemeManager.cs" /> <Compile Include="TV\TVSeriesManager.cs" /> <Compile Include="Udp\UdpMessageReceivedEventArgs.cs" /> <Compile Include="Udp\UdpServer.cs" /> diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs index 6b99883a5..9ea553d2d 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -138,7 +138,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder try { - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); using (var stream = await _encoder.ExtractVideoImage(inputPath, protocol, video.Video3DFormat, time, cancellationToken).ConfigureAwait(false)) { diff --git a/MediaBrowser.Server.Implementations/News/NewsEntryPoint.cs b/MediaBrowser.Server.Implementations/News/NewsEntryPoint.cs index 619384b6f..0266756c3 100644 --- a/MediaBrowser.Server.Implementations/News/NewsEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/News/NewsEntryPoint.cs @@ -71,7 +71,7 @@ namespace MediaBrowser.Server.Implementations.News { DateTime? lastUpdate = null; - if (File.Exists(path)) + if (_fileSystem.FileExists(path)) { lastUpdate = _fileSystem.GetLastWriteTimeUtc(path); } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 5ad6449b3..e2b85743b 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -617,7 +617,7 @@ namespace MediaBrowser.Server.Implementations.Persistence /// <returns>Task.</returns> public Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews) { - Directory.CreateDirectory(_criticReviewsPath); + _fileSystem.CreateDirectory(_criticReviewsPath); var path = Path.Combine(_criticReviewsPath, itemId + ".json"); diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs index 4b7e1c3a7..bd5c571fe 100644 --- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.Photos CancellationToken cancellationToken) { var outputPath = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid() + ".png"); - Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); var imageCreated = await CreateImage(item, itemsWithImages, outputPath, imageType, 0).ConfigureAwait(false); if (!imageCreated) @@ -145,7 +145,7 @@ namespace MediaBrowser.Server.Implementations.Photos private Task<bool> CreateCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height) { - Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath)); var options = new ImageCollageOptions { diff --git a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs index 3ec41b6dc..4c972d23d 100644 --- a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs +++ b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs @@ -56,7 +56,7 @@ namespace MediaBrowser.Server.Implementations.Playlists { var path = Path.Combine(_appPaths.DataPath, "playlists"); - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); return new PlaylistsFolder { diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs index 857cf743f..542fa14c5 100644 --- a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs +++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs @@ -110,7 +110,7 @@ namespace MediaBrowser.Server.Implementations.Playlists try { - Directory.CreateDirectory(path); + _fileSystem.CreateDirectory(path); var playlist = new Playlist { @@ -150,7 +150,7 @@ namespace MediaBrowser.Server.Implementations.Playlists private string GetTargetPath(string path) { - while (Directory.Exists(path)) + while (_fileSystem.DirectoryExists(path)) { path += "1"; } diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs index b23aaeeff..4e9d9ab18 100644 --- a/MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs +++ b/MediaBrowser.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs @@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks try { - previouslyFailedImages = File.ReadAllText(failHistoryPath) + previouslyFailedImages = _fileSystem.ReadAllText(failHistoryPath) .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) .ToList(); } @@ -132,9 +132,9 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks var parentPath = Path.GetDirectoryName(failHistoryPath); - Directory.CreateDirectory(parentPath); + _fileSystem.CreateDirectory(parentPath); - File.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray())); + _fileSystem.WriteAllText(failHistoryPath, string.Join("|", previouslyFailedImages.ToArray())); } numComplete++; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 1061a373e..c9099dbe7 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -702,7 +702,7 @@ namespace MediaBrowser.Server.Implementations.Sync var path = Path.Combine(temporaryPath, filename); - Directory.CreateDirectory(Path.GetDirectoryName(path)); + _fileSystem.CreateDirectory(Path.GetDirectoryName(path)); using (var stream = await _subtitleEncoder.GetSubtitles(streamInfo.ItemId, streamInfo.MediaSourceId, subtitleStreamIndex, subtitleStreamInfo.Format, 0, null, cancellationToken).ConfigureAwait(false)) { diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index f7a87dad5..428ba5e20 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -516,55 +516,25 @@ namespace MediaBrowser.Server.Implementations.Sync return false; } - if (!item.RunTimeTicks.HasValue) - { - return false; - } - var video = item as Video; if (video != null) { - if (video.VideoType == VideoType.Iso || video.VideoType == VideoType.HdDvd) - { - return false; - } - if (video.IsPlaceHolder) { return false; } - if (video.IsArchive) - { - return false; - } - if (video.IsShortcut) { return false; } } - var game = item as Game; - if (game != null) - { - if (game.IsMultiPart) - { - return false; - } - } - if (item is LiveTvChannel || item is IChannelItem) { return false; } - // It would be nice to support these later - if (item is Game || item is Book) - { - return false; - } - return true; } diff --git a/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs b/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs deleted file mode 100644 index 2711c08aa..000000000 --- a/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs +++ /dev/null @@ -1,168 +0,0 @@ -using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller; -using MediaBrowser.Controller.Themes; -using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Themes; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace MediaBrowser.Server.Implementations.Themes -{ - public class AppThemeManager : IAppThemeManager - { - private readonly IServerApplicationPaths _appPaths; - private readonly IFileSystem _fileSystem; - private readonly IJsonSerializer _json; - private readonly ILogger _logger; - - private readonly string[] _supportedImageExtensions = { ".png", ".jpg", ".jpeg" }; - - public AppThemeManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer json, ILogger logger) - { - _appPaths = appPaths; - _fileSystem = fileSystem; - _json = json; - _logger = logger; - } - - private string ThemePath - { - get - { - return Path.Combine(_appPaths.ProgramDataPath, "appthemes"); - } - } - - private string GetThemesPath(string applicationName) - { - if (string.IsNullOrWhiteSpace(applicationName)) - { - throw new ArgumentNullException("applicationName"); - } - - // Force everything lowercase for consistency and maximum compatibility with case-sensitive file systems - var name = _fileSystem.GetValidFilename(applicationName.ToLower()); - - return Path.Combine(ThemePath, name); - } - - private string GetThemePath(string applicationName, string name) - { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentNullException("name"); - } - - // Force everything lowercase for consistency and maximum compatibility with case-sensitive file systems - name = _fileSystem.GetValidFilename(name.ToLower()); - - return Path.Combine(GetThemesPath(applicationName), name); - } - - private string GetImagesPath(string applicationName, string themeName) - { - return Path.Combine(GetThemePath(applicationName, themeName), "images"); - } - - public IEnumerable<AppThemeInfo> GetThemes(string applicationName) - { - var path = GetThemesPath(applicationName); - - try - { - return Directory - .EnumerateFiles(path, "*", SearchOption.AllDirectories) - .Where(i => string.Equals(Path.GetExtension(i), ".json", StringComparison.OrdinalIgnoreCase)) - .Select(i => - { - try - { - return _json.DeserializeFromFile<AppThemeInfo>(i); - } - catch (Exception ex) - { - _logger.ErrorException("Error deserializing {0}", ex, i); - return null; - } - - }).Where(i => i != null); - } - catch (DirectoryNotFoundException) - { - return new List<AppThemeInfo>(); - } - } - - public AppTheme GetTheme(string applicationName, string name) - { - var themePath = GetThemePath(applicationName, name); - var file = Path.Combine(themePath, "theme.json"); - - var imagesPath = GetImagesPath(applicationName, name); - - var theme = _json.DeserializeFromFile<AppTheme>(file); - - theme.Images = new DirectoryInfo(imagesPath) - .EnumerateFiles("*", SearchOption.TopDirectoryOnly) - .Where(i => _supportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) - .Select(GetThemeImage) - .ToList(); - - return theme; - } - - private ThemeImage GetThemeImage(FileInfo file) - { - var dateModified = _fileSystem.GetLastWriteTimeUtc(file); - - var cacheTag = (file.FullName + dateModified.Ticks).GetMD5().ToString("N"); - - return new ThemeImage - { - CacheTag = cacheTag, - Name = file.Name - }; - } - - public void SaveTheme(AppTheme theme) - { - var themePath = GetThemePath(theme.AppName, theme.Name); - var file = Path.Combine(themePath, "theme.json"); - - Directory.CreateDirectory(themePath); - - // Clone it so that we don't serialize all the images - they're always dynamic - var clone = new AppTheme - { - AppName = theme.AppName, - Name = theme.Name, - Options = theme.Options, - Images = null - }; - - _json.SerializeToFile(clone, file); - } - - public InternalThemeImage GetImageImageInfo(string applicationName, string themeName, string imageName) - { - var imagesPath = GetImagesPath(applicationName, themeName); - - var file = new DirectoryInfo(imagesPath).EnumerateFiles("*", SearchOption.TopDirectoryOnly) - .First(i => string.Equals(i.Name, imageName, StringComparison.OrdinalIgnoreCase)); - - var themeImage = GetThemeImage(file); - - return new InternalThemeImage - { - CacheTag = themeImage.CacheTag, - Name = themeImage.Name, - Path = file.FullName, - DateModified = _fileSystem.GetLastWriteTimeUtc(file) - }; - } - } -} |
