diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs
index 5cd0aae808..018d8a92ef 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
/// The logger.
private ILogger Logger { get; set; }
+ private readonly IServerApplicationPaths AppPaths;
+
///
/// Initializes a new instance of the class.
///
/// The logger.
- public ApiEntryPoint(ILogger logger)
+ public ApiEntryPoint(ILogger logger, IServerApplicationPaths appPaths)
{
Logger = logger;
+ AppPaths = appPaths;
Instance = this;
}
@@ -43,6 +48,27 @@ namespace MediaBrowser.Api
///
public void Run()
{
+ try
+ {
+ DeleteEncodedMediaCache();
+ }
+ catch (IOException ex)
+ {
+ Logger.ErrorException("Error deleting encoded media cache", ex);
+ }
+ }
+
+ ///
+ /// Deletes the encoded media cache.
+ ///
+ private void DeleteEncodedMediaCache()
+ {
+ foreach (var file in Directory.EnumerateFiles(AppPaths.EncodedMediaCachePath)
+ .Where(i => EntityResolutionHelper.VideoFileExtensions.Contains(Path.GetExtension(i)))
+ .ToList())
+ {
+ File.Delete(file);
+ }
}
///
@@ -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
{