2017-09-05 19:49:02 +00:00
|
|
|
|
using System;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
2013-03-08 05:08:27 +00:00
|
|
|
|
using System.Threading;
|
2017-09-18 16:52:22 +00:00
|
|
|
|
using MediaBrowser.Model.Tasks;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
2013-03-08 05:08:27 +00:00
|
|
|
|
|
2016-11-03 22:06:00 +00:00
|
|
|
|
namespace Emby.Server.Implementations.EntryPoints
|
2013-03-08 05:08:27 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class RefreshUsersMetadata
|
|
|
|
|
/// </summary>
|
2017-09-18 16:52:22 +00:00
|
|
|
|
public class RefreshUsersMetadata : IScheduledTask, IConfigurableScheduledTask
|
2013-03-08 05:08:27 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _user manager
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly IUserManager _userManager;
|
2017-09-18 16:52:22 +00:00
|
|
|
|
private IFileSystem _fileSystem;
|
|
|
|
|
|
|
|
|
|
public string Name => "Refresh Users";
|
|
|
|
|
|
|
|
|
|
public string Key => "RefreshUsers";
|
|
|
|
|
|
|
|
|
|
public string Description => "Refresh user infos";
|
|
|
|
|
|
|
|
|
|
public string Category
|
|
|
|
|
{
|
|
|
|
|
get { return "Library"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsHidden => true;
|
|
|
|
|
|
|
|
|
|
public bool IsEnabled => true;
|
|
|
|
|
|
|
|
|
|
public bool IsLogged => true;
|
2013-03-08 05:08:27 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="RefreshUsersMetadata" /> class.
|
|
|
|
|
/// </summary>
|
2017-09-18 16:52:22 +00:00
|
|
|
|
public RefreshUsersMetadata(IUserManager userManager, IFileSystem fileSystem)
|
2013-03-08 05:08:27 +00:00
|
|
|
|
{
|
|
|
|
|
_userManager = userManager;
|
2017-09-18 16:52:22 +00:00
|
|
|
|
_fileSystem = fileSystem;
|
2013-03-08 05:08:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 16:52:22 +00:00
|
|
|
|
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
2013-03-08 05:08:27 +00:00
|
|
|
|
{
|
2017-09-18 16:52:22 +00:00
|
|
|
|
var users = _userManager.Users.ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var user in users)
|
|
|
|
|
{
|
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
|
|
|
|
await user.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken).ConfigureAwait(false);
|
|
|
|
|
}
|
2013-03-08 05:08:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 16:52:22 +00:00
|
|
|
|
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
|
2013-03-08 05:08:27 +00:00
|
|
|
|
{
|
2017-09-18 16:52:22 +00:00
|
|
|
|
return new List<TaskTriggerInfo>
|
|
|
|
|
{
|
|
|
|
|
new TaskTriggerInfo
|
|
|
|
|
{
|
|
|
|
|
IntervalTicks = TimeSpan.FromDays(1).Ticks,
|
|
|
|
|
Type = TaskTriggerInfo.TriggerInterval
|
2017-09-21 20:54:42 +00:00
|
|
|
|
},
|
|
|
|
|
new TaskTriggerInfo
|
|
|
|
|
{
|
|
|
|
|
Type = TaskTriggerInfo.TriggerStartup
|
2017-09-18 16:52:22 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2013-03-08 05:08:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|