mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 06:48:35 +01:00
reduce system info refreshing from dashboard
This commit is contained in:
@@ -208,15 +208,27 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
|
||||
private WatchedIndicatorDrawer _watchedDrawer;
|
||||
|
||||
private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageOverlay indicator)
|
||||
private void DrawIndicator(Graphics graphics, int imageWidth, int imageHeight, ImageOverlay? indicator)
|
||||
{
|
||||
if (indicator == ImageOverlay.Watched)
|
||||
if (!indicator.HasValue)
|
||||
{
|
||||
_watchedDrawer = _watchedDrawer ?? (_watchedDrawer = new WatchedIndicatorDrawer());
|
||||
return;
|
||||
}
|
||||
|
||||
var currentImageSize = new Size(imageWidth, imageHeight);
|
||||
try
|
||||
{
|
||||
if (indicator.Value == ImageOverlay.Watched)
|
||||
{
|
||||
_watchedDrawer = _watchedDrawer ?? (_watchedDrawer = new WatchedIndicatorDrawer());
|
||||
|
||||
_watchedDrawer.Process(graphics, currentImageSize);
|
||||
var currentImageSize = new Size(imageWidth, imageHeight);
|
||||
|
||||
_watchedDrawer.Process(graphics, currentImageSize);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error drawing indicator overlay", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,7 +350,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
/// <summary>
|
||||
/// Gets the cache file path based on a set of parameters
|
||||
/// </summary>
|
||||
private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, ImageOverlay overlay)
|
||||
private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageOutputFormat format, ImageOverlay? overlay)
|
||||
{
|
||||
var filename = originalPath;
|
||||
|
||||
@@ -355,9 +367,9 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
filename += "format=" + format;
|
||||
}
|
||||
|
||||
if (overlay != ImageOverlay.None)
|
||||
if (overlay.HasValue)
|
||||
{
|
||||
filename += "overlay=" + overlay;
|
||||
filename += "overlay=" + overlay.Value;
|
||||
}
|
||||
|
||||
return GetCachePath(_resizedImageCachePath, filename, Path.GetExtension(originalPath));
|
||||
@@ -414,9 +426,13 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
|
||||
try
|
||||
{
|
||||
var result = File.ReadAllText(fullCachePath).Split('|').Select(i => double.Parse(i, UsCulture)).ToArray();
|
||||
var result = File.ReadAllText(fullCachePath).Split('|');
|
||||
|
||||
return new ImageSize { Width = result[0], Height = result[1] };
|
||||
return new ImageSize
|
||||
{
|
||||
Width = double.Parse(result[0], UsCulture),
|
||||
Height = double.Parse(result[1], UsCulture)
|
||||
};
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
@@ -429,12 +445,13 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = File.ReadAllText(fullCachePath)
|
||||
.Split('|')
|
||||
.Select(i => double.Parse(i, UsCulture))
|
||||
.ToArray();
|
||||
var result = File.ReadAllText(fullCachePath).Split('|');
|
||||
|
||||
return new ImageSize { Width = result[0], Height = result[1] };
|
||||
return new ImageSize
|
||||
{
|
||||
Width = double.Parse(result[0], UsCulture),
|
||||
Height = double.Parse(result[1], UsCulture)
|
||||
};
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <param name="searchInput">The search input.</param>
|
||||
/// <param name="searchWords">The search input.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
private Tuple<string, int> GetIndex(string input, string searchInput, string[] searchWords)
|
||||
private Tuple<string, int> GetIndex(string input, string searchInput, List<string> searchWords)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
@@ -324,11 +324,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
var items = GetWords(input);
|
||||
|
||||
for (var i = 0; i < searchWords.Length; i++)
|
||||
for (var i = 0; i < searchWords.Count; i++)
|
||||
{
|
||||
var searchTerm = searchWords[i];
|
||||
|
||||
for (var j = 0; j < items.Length; j++)
|
||||
for (var j = 0; j < items.Count; j++)
|
||||
{
|
||||
var item = items[j];
|
||||
|
||||
@@ -357,9 +357,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// </summary>
|
||||
/// <param name="term">The term.</param>
|
||||
/// <returns>System.String[][].</returns>
|
||||
private string[] GetWords(string term)
|
||||
private List<string> GetWords(string term)
|
||||
{
|
||||
return term.Split().Where(i => !string.IsNullOrWhiteSpace(i)).ToArray();
|
||||
return term.Split().Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToArray();
|
||||
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToList();
|
||||
|
||||
var allMusicArtists = allItems.OfType<MusicArtist>().ToArray();
|
||||
var allSongs = allItems.OfType<Audio>().ToArray();
|
||||
var allMusicArtists = allItems.OfType<MusicArtist>().ToList();
|
||||
var allSongs = allItems.OfType<Audio>().ToList();
|
||||
|
||||
var innerProgress = new ActionableProgress<double>();
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
var numComplete = 0;
|
||||
|
||||
var userLibraries = _userManager.Users
|
||||
.Select(i => new Tuple<Guid, IHasArtist[]>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<IHasArtist>().ToArray()))
|
||||
.ToArray();
|
||||
.Select(i => new Tuple<Guid, List<IHasArtist>>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<IHasArtist>().ToList()))
|
||||
.ToList();
|
||||
|
||||
var numArtists = allArtists.Count;
|
||||
|
||||
@@ -140,11 +140,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
var items = allItems
|
||||
.Where(i => i.HasArtist(name))
|
||||
.ToArray();
|
||||
.ToList();
|
||||
|
||||
var counts = new ItemByNameCounts
|
||||
{
|
||||
TotalCount = items.Length,
|
||||
TotalCount = items.Count,
|
||||
|
||||
SongCount = items.OfType<Audio>().Count(),
|
||||
|
||||
@@ -167,7 +167,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
private void MergeImages(Dictionary<ImageType, string> source, Dictionary<ImageType, string> target)
|
||||
{
|
||||
foreach (var key in source.Keys
|
||||
.ToArray()
|
||||
.Where(k => !target.ContainsKey(k)))
|
||||
{
|
||||
string path;
|
||||
@@ -202,7 +201,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
return list;
|
||||
})
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
.ToList();
|
||||
|
||||
const int maxTasks = 3;
|
||||
|
||||
@@ -211,6 +210,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
var returnArtists = new ConcurrentBag<Artist>();
|
||||
|
||||
var numComplete = 0;
|
||||
var numArtists = allArtists.Count;
|
||||
|
||||
foreach (var artist in allArtists)
|
||||
{
|
||||
@@ -248,7 +248,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
{
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= allArtists.Length;
|
||||
percent /= numArtists;
|
||||
|
||||
progress.Report(100 * percent);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
private void RunInternal(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var userLibraries = _userManager.Users
|
||||
.Select(i => new Tuple<Guid, BaseItem[]>(i.Id, i.RootFolder.GetRecursiveChildren(i).ToArray()))
|
||||
.Select(i => new Tuple<Guid, List<BaseItem>>(i.Id, i.RootFolder.GetRecursiveChildren(i).ToList()))
|
||||
.ToList();
|
||||
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -118,7 +118,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
var names = media
|
||||
.People.Select(i => i.Name)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
.ToList();
|
||||
|
||||
CountHelpers.SetItemCounts(userId, media, names, masterDictionary);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user