aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ServerApplication')
-rw-r--r--MediaBrowser.ServerApplication/ApplicationHost.cs6
-rw-r--r--MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs21
-rw-r--r--MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs54
-rw-r--r--MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj3
-rw-r--r--MediaBrowser.ServerApplication/packages.config1
5 files changed, 45 insertions, 40 deletions
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 5cae99785..a2965d4ea 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -258,6 +258,8 @@ namespace MediaBrowser.ServerApplication
ZipClient = new DotNetZipClient();
RegisterSingleInstance(ZipClient);
+ var mediaEncoderTask = RegisterMediaEncoder();
+
UserDataRepository = new SqliteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager);
RegisterSingleInstance(UserDataRepository);
@@ -284,8 +286,6 @@ namespace MediaBrowser.ServerApplication
RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager));
- await RegisterMediaEncoder().ConfigureAwait(false);
-
var clientConnectionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository);
RegisterSingleInstance<ISessionManager>(clientConnectionManager);
@@ -310,7 +310,7 @@ namespace MediaBrowser.ServerApplication
await ConfigureNotificationsRepository().ConfigureAwait(false);
- await Task.WhenAll(itemsTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
+ await Task.WhenAll(itemsTask, displayPreferencesTask, userdataTask, mediaEncoderTask).ConfigureAwait(false);
SetKernelProperties();
}
diff --git a/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs b/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs
index 3b174a9b2..4a9afac3f 100644
--- a/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs
+++ b/MediaBrowser.ServerApplication/Implementations/DotNetZipClient.cs
@@ -1,5 +1,6 @@
-using Ionic.Zip;
-using MediaBrowser.Model.IO;
+using MediaBrowser.Model.IO;
+using SharpCompress.Common;
+using SharpCompress.Reader;
using System.IO;
namespace MediaBrowser.ServerApplication.Implementations
@@ -19,10 +20,7 @@ namespace MediaBrowser.ServerApplication.Implementations
{
using (var fileStream = File.OpenRead(sourceFile))
{
- using (var zipFile = ZipFile.Read(fileStream))
- {
- zipFile.ExtractAll(targetPath, overwriteExistingFiles ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
- }
+ ExtractAll(fileStream, targetPath, overwriteExistingFiles);
}
}
@@ -34,9 +32,16 @@ namespace MediaBrowser.ServerApplication.Implementations
/// <param name="overwriteExistingFiles">if set to <c>true</c> [overwrite existing files].</param>
public void ExtractAll(Stream source, string targetPath, bool overwriteExistingFiles)
{
- using (var zipFile = ZipFile.Read(source))
+ using (var reader = ReaderFactory.Open(source))
{
- zipFile.ExtractAll(targetPath, overwriteExistingFiles ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
+ var options = ExtractOptions.ExtractFullPath;
+
+ if (overwriteExistingFiles)
+ {
+ options = options | ExtractOptions.Overwrite;
+ }
+
+ reader.WriteAllToDirectory(targetPath, options);
}
}
}
diff --git a/MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs b/MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs
index 7fd0acddd..becb8d8ab 100644
--- a/MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs
+++ b/MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs
@@ -6,7 +6,6 @@ using MediaBrowser.Model.Logging;
using System;
using System.IO;
using System.Linq;
-using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -29,33 +28,37 @@ namespace MediaBrowser.ServerApplication.Implementations
public async Task<FFMpegInfo> GetFFMpegInfo()
{
- var assembly = GetType().Assembly;
+ var version = "ffmpeg20130904";
- var prefix = GetType().Namespace + ".";
+ var versionedDirectoryPath = Path.Combine(GetMediaToolsPath(true), version);
- var srch = prefix + "ffmpeg";
-
- var resource = assembly.GetManifestResourceNames().First(r => r.StartsWith(srch));
-
- var filename =
- resource.Substring(resource.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) + prefix.Length);
-
- var versionedDirectoryPath = Path.Combine(GetMediaToolsPath(true),
- Path.GetFileNameWithoutExtension(filename));
+ var info = new FFMpegInfo
+ {
+ ProbePath = Path.Combine(versionedDirectoryPath, "ffprobe.exe"),
+ Path = Path.Combine(versionedDirectoryPath, "ffmpeg.exe"),
+ Version = version
+ };
if (!Directory.Exists(versionedDirectoryPath))
{
Directory.CreateDirectory(versionedDirectoryPath);
}
- await ExtractTools(assembly, resource, versionedDirectoryPath).ConfigureAwait(false);
+ if (!File.Exists(info.ProbePath) || !File.Exists(info.Path))
+ {
+ ExtractTools(version, versionedDirectoryPath);
+ }
- return new FFMpegInfo
+ try
{
- ProbePath = Path.Combine(versionedDirectoryPath, "ffprobe.exe"),
- Path = Path.Combine(versionedDirectoryPath, "ffmpeg.exe"),
- Version = Path.GetFileNameWithoutExtension(versionedDirectoryPath)
- };
+ await DownloadFonts(versionedDirectoryPath).ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("Error getting ffmpeg font files", ex);
+ }
+
+ return info;
}
/// <summary>
@@ -64,20 +67,13 @@ namespace MediaBrowser.ServerApplication.Implementations
/// <param name="assembly">The assembly.</param>
/// <param name="zipFileResourcePath">The zip file resource path.</param>
/// <param name="targetPath">The target path.</param>
- private async Task ExtractTools(Assembly assembly, string zipFileResourcePath, string targetPath)
+ private void ExtractTools(string version, string targetPath)
{
- using (var resourceStream = assembly.GetManifestResourceStream(zipFileResourcePath))
- {
- _zipClient.ExtractAll(resourceStream, targetPath, false);
- }
+ var zipFileResourcePath = GetType().Namespace + "." + version + ".zip";
- try
+ using (var resourceStream = GetType().Assembly.GetManifestResourceStream(zipFileResourcePath))
{
- await DownloadFonts(targetPath).ConfigureAwait(false);
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error getting ffmpeg font files", ex);
+ _zipClient.ExtractAll(resourceStream, targetPath, false);
}
}
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index 043d5c18f..965e9f873 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -168,6 +168,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
+ <Reference Include="SharpCompress">
+ <HintPath>..\packages\sharpcompress.0.10.1.3\lib\net40\SharpCompress.dll</HintPath>
+ </Reference>
<Reference Include="SimpleInjector, Version=2.3.5.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\SimpleInjector.2.3.5\lib\net40-client\SimpleInjector.dll</HintPath>
diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config
index 8c1821ca5..137483ef1 100644
--- a/MediaBrowser.ServerApplication/packages.config
+++ b/MediaBrowser.ServerApplication/packages.config
@@ -11,6 +11,7 @@
<package id="ServiceStack.OrmLite.SqlServer" version="3.9.44" targetFramework="net45" />
<package id="ServiceStack.Redis" version="3.9.44" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" />
+ <package id="sharpcompress" version="0.10.1.3" targetFramework="net45" />
<package id="SimpleInjector" version="2.3.5" targetFramework="net45" />
<package id="System.Data.SQLite.x86" version="1.0.88.0" targetFramework="net45" />
</packages> \ No newline at end of file