From df311b2916d3aba02d0749cc8cdfbc4811de50c5 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Sun, 20 Dec 2015 17:58:58 +0100 Subject: [PATCH] Webserver: Added a threshold to the config which decides at how many song we stop sending covers on get-all-songs requests. --- Vocaluxe/Base/CConfig.cs | 3 +++ Vocaluxe/Base/Server/CVocaluxeServer.cs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 6409815a..ea133582 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -163,6 +163,7 @@ namespace Vocaluxe.Base [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn ServerActive; [DefaultValue(EOffOn.TR_CONFIG_OFF)] public EOffOn ServerEncryption; [DefaultValue(3000)] public int ServerPort; + [DefaultValue(70)] public int SongCountCoverThreshold; } #pragma warning restore 649 // ReSharper restore UnassignedField.Global @@ -495,6 +496,8 @@ namespace Vocaluxe.Base return "Server Encryption On/Off: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); case "ServerPort": return "Server Port (default: 3000) [1..65535]"; + case "SongCountCoverThreshold": + return "Threshold of songs for that covers will not longer be included in get-all-songs-requests (e.g. song list) (default: 70) [-1..65535] -1 => always deliver covers"; case "Stretch": return "Stretch view to full window size: " + CHelper.ListStrings(Enum.GetNames(typeof(EOffOn))); default: diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index 6bce25f9..20e0cf20 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -628,11 +628,13 @@ namespace Vocaluxe.Base.Server private static SSongInfo[] songInfoCache = null; public static SSongInfo[] GetAllSongs() { + bool sendCovers = CConfig.Config.Server.SongCountCoverThreshold == -1 || CConfig.Config.Server.SongCountCoverThreshold > CSongs.Songs.Count; + if (songInfoCache == null) { List songs = CSongs.Songs; songInfoCache = (from s in songs - select _GetSongInfo(s, false)).AsParallel().ToArray(); + select _GetSongInfo(s, sendCovers)).AsParallel().ToArray(); } return songInfoCache;