Merge pull request #1934 from dkanada/transcode

Minor changes to transcode cleanup scheduled task
This commit is contained in:
Bond-009 2019-11-21 16:18:46 +01:00 committed by GitHub
commit d868a8da6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 35 deletions

View File

@ -456,7 +456,7 @@ namespace Emby.Server.Implementations
public string Name => ApplicationProductName; public string Name => ApplicationProductName;
/// <summary> /// <summary>
/// Creates an instance of type and resolves all constructor dependencies /// Creates an instance of type and resolves all constructor dependencies.
/// </summary> /// </summary>
/// <param name="type">The type.</param> /// <param name="type">The type.</param>
/// <returns>System.Object.</returns> /// <returns>System.Object.</returns>
@ -464,7 +464,7 @@ namespace Emby.Server.Implementations
=> ActivatorUtilities.CreateInstance(_serviceProvider, type); => ActivatorUtilities.CreateInstance(_serviceProvider, type);
/// <summary> /// <summary>
/// Creates an instance of type and resolves all constructor dependencies /// Creates an instance of type and resolves all constructor dependencies.
/// </summary> /// </summary>
/// /// <typeparam name="T">The type.</typeparam> /// /// <typeparam name="T">The type.</typeparam>
/// <returns>T.</returns> /// <returns>T.</returns>
@ -512,11 +512,12 @@ namespace Emby.Server.Implementations
/// <inheritdoc /> /// <inheritdoc />
public IReadOnlyCollection<T> GetExports<T>(bool manageLifetime = true) public IReadOnlyCollection<T> GetExports<T>(bool manageLifetime = true)
{ {
// Convert to list so this isn't executed for each iteration
var parts = GetExportTypes<T>() var parts = GetExportTypes<T>()
.Select(CreateInstanceSafe) .Select(CreateInstanceSafe)
.Where(i => i != null) .Where(i => i != null)
.Cast<T>() .Cast<T>()
.ToList(); // Convert to list so this isn't executed for each iteration .ToList();
if (manageLifetime) if (manageLifetime)
{ {
@ -1418,7 +1419,7 @@ namespace Emby.Server.Implementations
/// <summary> /// <summary>
/// Gets the system status. /// Gets the system status.
/// </summary> /// </summary>
/// <param name="cancellationToken">The cancellation token</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>SystemInfo.</returns> /// <returns>SystemInfo.</returns>
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken) public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
{ {
@ -1446,7 +1447,7 @@ namespace Emby.Server.Implementations
CanSelfRestart = CanSelfRestart, CanSelfRestart = CanSelfRestart,
CanLaunchWebBrowser = CanLaunchWebBrowser, CanLaunchWebBrowser = CanLaunchWebBrowser,
HasUpdateAvailable = HasUpdateAvailable, HasUpdateAvailable = HasUpdateAvailable,
TranscodingTempPath = ApplicationPaths.TranscodingTempPath, TranscodingTempPath = ApplicationPaths.TranscodePath,
ServerName = FriendlyName, ServerName = FriendlyName,
LocalAddress = localAddress, LocalAddress = localAddress,
SupportsLibraryMonitor = true, SupportsLibraryMonitor = true,
@ -1847,6 +1848,7 @@ namespace Emby.Server.Implementations
internal class CertificateInfo internal class CertificateInfo
{ {
public string Path { get; set; } public string Path { get; set; }
public string Password { get; set; } public string Password { get; set; }
} }
} }

View File

@ -91,7 +91,7 @@ namespace Emby.Server.Implementations.Configuration
{ {
var encodingConfig = this.GetConfiguration<EncodingOptions>("encoding"); var encodingConfig = this.GetConfiguration<EncodingOptions>("encoding");
((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(encodingConfig.TranscodingTempPath) ? ((ServerApplicationPaths)ApplicationPaths).TranscodePath = string.IsNullOrEmpty(encodingConfig.TranscodingTempPath) ?
null : null :
Path.Combine(encodingConfig.TranscodingTempPath, "transcodes"); Path.Combine(encodingConfig.TranscodingTempPath, "transcodes");
} }

View File

@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.EntryPoints
public class LibraryChangedNotifier : IServerEntryPoint public class LibraryChangedNotifier : IServerEntryPoint
{ {
/// <summary> /// <summary>
/// The _library manager /// The library manager.
/// </summary> /// </summary>
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.EntryPoints
private readonly ILogger _logger; private readonly ILogger _logger;
/// <summary> /// <summary>
/// The _library changed sync lock /// The library changed sync lock.
/// </summary> /// </summary>
private readonly object _libraryChangedSyncLock = new object(); private readonly object _libraryChangedSyncLock = new object();
@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.EntryPoints
private Timer LibraryUpdateTimer { get; set; } private Timer LibraryUpdateTimer { get; set; }
/// <summary> /// <summary>
/// The library update duration /// The library update duration.
/// </summary> /// </summary>
private const int LibraryUpdateDuration = 30000; private const int LibraryUpdateDuration = 30000;
@ -188,8 +188,11 @@ namespace Emby.Server.Implementations.EntryPoints
{ {
if (LibraryUpdateTimer == null) if (LibraryUpdateTimer == null)
{ {
LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration, LibraryUpdateTimer = new Timer(
Timeout.Infinite); LibraryUpdateTimerCallback,
null,
LibraryUpdateDuration,
Timeout.Infinite);
} }
else else
{ {

View File

@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
protected void SetTempFilePath(string extension) protected void SetTempFilePath(string extension)
{ {
TempFilePath = Path.Combine(AppPaths.GetTranscodingTempPath(), UniqueId + "." + extension); TempFilePath = Path.Combine(AppPaths.GetTranscodePath(), UniqueId + "." + extension);
} }
public virtual Task Open(CancellationToken openCancellationToken) public virtual Task Open(CancellationToken openCancellationToken)

View File

@ -54,7 +54,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
try try
{ {
DeleteTempFilesFromDirectory(cancellationToken, ApplicationPaths.TranscodingTempPath, minDateModified, progress); DeleteTempFilesFromDirectory(cancellationToken, ApplicationPaths.TranscodePath, minDateModified, progress);
} }
catch (DirectoryNotFoundException) catch (DirectoryNotFoundException)
{ {
@ -138,13 +138,13 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
} }
} }
public string Name => "Transcoding temp cleanup"; public string Name => "Transcode file cleanup";
public string Description => "Deletes transcoding temp files older than 24 hours."; public string Description => "Deletes transcode files more than 24 hours old.";
public string Category => "Maintenance"; public string Category => "Maintenance";
public string Key => "DeleteTranscodingTempFiles"; public string Key => "DeleteTranscodeFiles";
public bool IsHidden => false; public bool IsHidden => false;

View File

@ -10,8 +10,8 @@ namespace Emby.Server.Implementations
/// </summary> /// </summary>
public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
{ {
private string _defaultTranscodingTempPath; private string _defaultTranscodePath;
private string _transcodingTempPath; private string _transcodePath;
private string _internalMetadataPath; private string _internalMetadataPath;
/// <summary> /// <summary>
@ -107,19 +107,19 @@ namespace Emby.Server.Implementations
/// <value>The user configuration directory path.</value> /// <value>The user configuration directory path.</value>
public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users"); public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users");
public string DefaultTranscodingTempPath => _defaultTranscodingTempPath ?? (_defaultTranscodingTempPath = Path.Combine(ProgramDataPath, "transcoding-temp")); public string DefaultTranscodePath => _defaultTranscodePath ?? (_defaultTranscodePath = Path.Combine(ProgramDataPath, "transcodes"));
public string TranscodingTempPath public string TranscodePath
{ {
get => _transcodingTempPath ?? (_transcodingTempPath = DefaultTranscodingTempPath); get => _transcodePath ?? (_transcodePath = DefaultTranscodePath);
set => _transcodingTempPath = value; set => _transcodePath = value;
} }
public string GetTranscodingTempPath() public string GetTranscodePath()
{ {
var path = TranscodingTempPath; var path = TranscodePath;
if (!string.Equals(path, DefaultTranscodingTempPath, StringComparison.OrdinalIgnoreCase)) if (!string.Equals(path, DefaultTranscodePath, StringComparison.OrdinalIgnoreCase))
{ {
try try
{ {
@ -136,7 +136,7 @@ namespace Emby.Server.Implementations
} }
} }
path = DefaultTranscodingTempPath; path = DefaultTranscodePath;
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
return path; return path;
} }

View File

@ -167,7 +167,7 @@ namespace MediaBrowser.Api
/// </summary> /// </summary>
private void DeleteEncodedMediaCache() private void DeleteEncodedMediaCache()
{ {
var path = ConfigurationManager.ApplicationPaths.GetTranscodingTempPath(); var path = ConfigurationManager.ApplicationPaths.GetTranscodePath();
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {

View File

@ -141,7 +141,7 @@ namespace MediaBrowser.Api.Playback
var filename = data.GetMD5().ToString("N", CultureInfo.InvariantCulture); var filename = data.GetMD5().ToString("N", CultureInfo.InvariantCulture);
var ext = outputFileExtension.ToLowerInvariant(); var ext = outputFileExtension.ToLowerInvariant();
var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath; var folder = ServerConfigurationManager.ApplicationPaths.TranscodePath;
if (EnableOutputInSubFolder) if (EnableOutputInSubFolder)
{ {

View File

@ -97,7 +97,7 @@ namespace MediaBrowser.Api.Playback.Hls
public Task<object> Get(GetHlsPlaylistLegacy request) public Task<object> Get(GetHlsPlaylistLegacy request)
{ {
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo); var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
file = Path.Combine(_appPaths.TranscodingTempPath, file); file = Path.Combine(_appPaths.TranscodePath, file);
return GetFileResult(file, file); return GetFileResult(file, file);
} }
@ -116,7 +116,7 @@ namespace MediaBrowser.Api.Playback.Hls
{ {
var file = request.SegmentId + Path.GetExtension(Request.PathInfo); var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
var transcodeFolderPath = _config.ApplicationPaths.TranscodingTempPath; var transcodeFolderPath = _config.ApplicationPaths.TranscodePath;
file = Path.Combine(transcodeFolderPath, file); file = Path.Combine(transcodeFolderPath, file);
var normalizedPlaylistId = request.PlaylistId; var normalizedPlaylistId = request.PlaylistId;
@ -136,7 +136,7 @@ namespace MediaBrowser.Api.Playback.Hls
{ {
// TODO: Deprecate with new iOS app // TODO: Deprecate with new iOS app
var file = request.SegmentId + Path.GetExtension(Request.PathInfo); var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
file = Path.Combine(_appPaths.TranscodingTempPath, file); file = Path.Combine(_appPaths.TranscodePath, file);
return ResultFactory.GetStaticFileResult(Request, file, FileShareMode.ReadWrite); return ResultFactory.GetStaticFileResult(Request, file, FileShareMode.ReadWrite);
} }

View File

@ -86,7 +86,7 @@ namespace MediaBrowser.Controller
/// Gets the transcoding temporary path. /// Gets the transcoding temporary path.
/// </summary> /// </summary>
/// <value>The transcoding temporary path.</value> /// <value>The transcoding temporary path.</value>
string TranscodingTempPath { get; } string TranscodePath { get; }
/// <summary> /// <summary>
/// Gets the internal metadata path. /// Gets the internal metadata path.
@ -97,6 +97,6 @@ namespace MediaBrowser.Controller
string ArtistsPath { get; } string ArtistsPath { get; }
string GetTranscodingTempPath(); string GetTranscodePath();
} }
} }

View File

@ -110,9 +110,9 @@ namespace MediaBrowser.Model.System
public string InternalMetadataPath { get; set; } public string InternalMetadataPath { get; set; }
/// <summary> /// <summary>
/// Gets or sets the transcoding temporary path. /// Gets or sets the transcode path.
/// </summary> /// </summary>
/// <value>The transcoding temporary path.</value> /// <value>The transcode path.</value>
public string TranscodingTempPath { get; set; } public string TranscodingTempPath { get; set; }
/// <summary> /// <summary>