mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 17:44:43 +01:00
Merge branch 'dev' of https://github.com/MediaBrowser/MediaBrowser into dev
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.Collections
|
||||
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
_fileSystem.CreateDirectory(path);
|
||||
|
||||
var collection = new BoxSet
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace MediaBrowser.Server.Implementations.Devices
|
||||
|
||||
_libraryMonitor.ReportFileSystemChangeBeginning(path);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) { }
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace MediaBrowser.Server.Implementations.News
|
||||
{
|
||||
DateTime? lastUpdate = null;
|
||||
|
||||
if (File.Exists(path))
|
||||
if (_fileSystem.FileExists(path))
|
||||
{
|
||||
lastUpdate = _fileSystem.GetLastWriteTimeUtc(path);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user