diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-09-14 11:10:51 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-09-14 11:10:51 -0400 |
| commit | 5c615fa02448813499ed87f2a1c2b937c7a7dcd5 (patch) | |
| tree | b96b07cb1d43006a8faa64649885fb808e18c43a /MediaBrowser.ServerApplication | |
| parent | 4f3ea6c6c3cdde7f4b8d21dc97c711635d73b4e0 (diff) | |
add connect linking
Diffstat (limited to 'MediaBrowser.ServerApplication')
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs | 33 |
2 files changed, 33 insertions, 2 deletions
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index b5db94776..0d76e95b9 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -447,7 +447,7 @@ namespace MediaBrowser.ServerApplication var encryptionManager = new EncryptionManager(); RegisterSingleInstance<IEncryptionManager>(encryptionManager); - ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager); + ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager); RegisterSingleInstance(ConnectManager); SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository); diff --git a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs index 4f94ebd67..ae11712a5 100644 --- a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs +++ b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.Collections.Generic; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Model.IO; @@ -52,6 +53,8 @@ namespace MediaBrowser.ServerApplication.FFMpeg Directory.CreateDirectory(versionedDirectoryPath); + var excludeFromDeletions = new List<string> { versionedDirectoryPath }; + if (!File.Exists(info.ProbePath) || !File.Exists(info.EncoderPath)) { // ffmpeg not present. See if there's an older version we can start with @@ -71,14 +74,42 @@ namespace MediaBrowser.ServerApplication.FFMpeg info = existingVersion; versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath); + + excludeFromDeletions.Add(versionedDirectoryPath); } } await DownloadFonts(versionedDirectoryPath).ConfigureAwait(false); + DeleteOlderFolders(Path.GetDirectoryName(versionedDirectoryPath), excludeFromDeletions); + return info; } + private void DeleteOlderFolders(string path, IEnumerable<string> excludeFolders ) + { + var folders = Directory.GetDirectories(path) + .Where(i => !excludeFolders.Contains(i, StringComparer.OrdinalIgnoreCase)) + .ToList(); + + foreach (var folder in folders) + { + DeleteFolder(folder); + } + } + + private void DeleteFolder(string path) + { + try + { + Directory.Delete(path, true); + } + catch (Exception ex) + { + _logger.ErrorException("Error deleting {0}", ex, path); + } + } + private FFMpegInfo GetExistingVersion(FFMpegInfo info, string rootEncoderPath) { var encoderFilename = Path.GetFileName(info.EncoderPath); |
