diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-12-14 18:21:03 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-12-14 18:21:03 -0500 |
| commit | d576108411d254afcbefa627cea6a2d3585ab823 (patch) | |
| tree | 3b5be28fdbc9ab3edc5db51ee243ac073b59723e | |
| parent | 0eea77b83737b5e20f8169a1cd2586c01bffcc68 (diff) | |
improve deletion of partially encoded files
| -rw-r--r-- | MediaBrowser.Api/ApiEntryPoint.cs | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 5cd0aae80..018d8a92e 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Controller.Plugins; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Plugins; +using MediaBrowser.Controller.Resolvers; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; @@ -27,13 +29,16 @@ namespace MediaBrowser.Api /// <value>The logger.</value> private ILogger Logger { get; set; } + private readonly IServerApplicationPaths AppPaths; + /// <summary> /// Initializes a new instance of the <see cref="ApiEntryPoint" /> class. /// </summary> /// <param name="logger">The logger.</param> - public ApiEntryPoint(ILogger logger) + public ApiEntryPoint(ILogger logger, IServerApplicationPaths appPaths) { Logger = logger; + AppPaths = appPaths; Instance = this; } @@ -43,6 +48,27 @@ namespace MediaBrowser.Api /// </summary> public void Run() { + try + { + DeleteEncodedMediaCache(); + } + catch (IOException ex) + { + Logger.ErrorException("Error deleting encoded media cache", ex); + } + } + + /// <summary> + /// Deletes the encoded media cache. + /// </summary> + private void DeleteEncodedMediaCache() + { + foreach (var file in Directory.EnumerateFiles(AppPaths.EncodedMediaCachePath) + .Where(i => EntityResolutionHelper.VideoFileExtensions.Contains(Path.GetExtension(i))) + .ToList()) + { + File.Delete(file); + } } /// <summary> @@ -317,7 +343,7 @@ namespace MediaBrowser.Api { Logger.Info("Deleting partial stream file(s) {0}", job.Path); - await Task.Delay(1000).ConfigureAwait(false); + await Task.Delay(1500).ConfigureAwait(false); try { |
