2019-01-13 12:54:44 -07:00
|
|
|
using System;
|
2017-09-18 09:52:22 -07:00
|
|
|
using System.Collections.Generic;
|
2019-01-13 12:20:41 -07:00
|
|
|
using System.Threading;
|
2017-09-18 09:52:22 -07:00
|
|
|
using System.Threading.Tasks;
|
2019-01-13 12:20:41 -07:00
|
|
|
using MediaBrowser.Controller.Library;
|
2017-09-18 09:52:22 -07:00
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
using MediaBrowser.Model.IO;
|
2019-01-13 12:20:41 -07:00
|
|
|
using MediaBrowser.Model.Tasks;
|
2013-03-07 22:08:27 -07:00
|
|
|
|
2016-11-03 15:06:00 -07:00
|
|
|
namespace Emby.Server.Implementations.EntryPoints
|
2013-03-07 22:08:27 -07:00
|
|
|
{
|
|
|
|
/// <summary>
|
2019-11-01 10:38:54 -07:00
|
|
|
/// Class RefreshUsersMetadata.
|
2013-03-07 22:08:27 -07:00
|
|
|
/// </summary>
|
2017-09-18 09:52:22 -07:00
|
|
|
public class RefreshUsersMetadata : IScheduledTask, IConfigurableScheduledTask
|
2013-03-07 22:08:27 -07:00
|
|
|
{
|
|
|
|
/// <summary>
|
2019-12-10 08:22:03 -07:00
|
|
|
/// The user manager.
|
2013-03-07 22:08:27 -07:00
|
|
|
/// </summary>
|
|
|
|
private readonly IUserManager _userManager;
|
2020-02-06 07:20:23 -07:00
|
|
|
private readonly IFileSystem _fileSystem;
|
2017-09-18 09:52:22 -07:00
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="RefreshUsersMetadata" /> class.
|
|
|
|
/// </summary>
|
2020-02-06 07:20:23 -07:00
|
|
|
public RefreshUsersMetadata(IUserManager userManager, IFileSystem fileSystem)
|
2019-11-01 10:38:54 -07:00
|
|
|
{
|
|
|
|
_userManager = userManager;
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2017-09-18 09:52:22 -07:00
|
|
|
public string Name => "Refresh Users";
|
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <inheritdoc />
|
2017-09-18 09:52:22 -07:00
|
|
|
public string Key => "RefreshUsers";
|
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <inheritdoc />
|
2017-09-18 09:52:22 -07:00
|
|
|
public string Description => "Refresh user infos";
|
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <inheritdoc />
|
2019-01-06 13:50:43 -07:00
|
|
|
public string Category => "Library";
|
2017-09-18 09:52:22 -07:00
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <inheritdoc />
|
2017-09-18 09:52:22 -07:00
|
|
|
public bool IsHidden => true;
|
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <inheritdoc />
|
2017-09-18 09:52:22 -07:00
|
|
|
public bool IsEnabled => true;
|
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <inheritdoc />
|
2017-09-18 09:52:22 -07:00
|
|
|
public bool IsLogged => true;
|
2013-03-07 22:08:27 -07:00
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <inheritdoc />
|
2017-09-18 09:52:22 -07:00
|
|
|
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
2013-03-07 22:08:27 -07:00
|
|
|
{
|
2019-06-09 13:08:01 -07:00
|
|
|
foreach (var user in _userManager.Users)
|
2017-09-18 09:52:22 -07:00
|
|
|
{
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
2019-09-10 13:37:53 -07:00
|
|
|
await user.RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(_fileSystem)), cancellationToken).ConfigureAwait(false);
|
2017-09-18 09:52:22 -07:00
|
|
|
}
|
2013-03-07 22:08:27 -07:00
|
|
|
}
|
|
|
|
|
2019-11-01 10:38:54 -07:00
|
|
|
/// <inheritdoc />
|
2017-09-18 09:52:22 -07:00
|
|
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
2013-03-07 22:08:27 -07:00
|
|
|
{
|
2019-11-01 10:38:54 -07:00
|
|
|
return new[]
|
2017-09-18 09:52:22 -07:00
|
|
|
{
|
|
|
|
new TaskTriggerInfo
|
|
|
|
{
|
|
|
|
IntervalTicks = TimeSpan.FromDays(1).Ticks,
|
|
|
|
Type = TaskTriggerInfo.TriggerInterval
|
|
|
|
}
|
|
|
|
};
|
2013-03-07 22:08:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|