aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2022-04-12 13:40:05 -0600
committerJoshua Boniface <joshua@boniface.me>2022-04-17 15:45:11 -0400
commit435fc7ade906162e0410e40844db03e9cecc69fb (patch)
treea31f2d7ed09012e13a2194734c130e132e48a206
parent7424f0ca8cef9ca1850420a5f3a5761ce764680b (diff)
Merge pull request #7567 from cvium/fix_xmltv_caching
(cherry picked from commit 385a0b94373606983051ff7662dfbe1e5514d4bc) Signed-off-by: Joshua Boniface <joshua@boniface.me>
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index 3da9d02b8..d56c9bb66 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -8,6 +8,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
+using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Extensions;
@@ -124,7 +125,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
using (var stream = File.OpenRead(file))
{
- string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
+ string tempFolder = GetTempFolderPath(stream);
Directory.CreateDirectory(tempFolder);
_zipClient.ExtractFirstFileFromGz(stream, tempFolder, "data.xml");
@@ -137,7 +138,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
{
using (var stream = File.OpenRead(file))
{
- string tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString());
+ string tempFolder = GetTempFolderPath(stream);
Directory.CreateDirectory(tempFolder);
_zipClient.ExtractAllFromGz(stream, tempFolder, true);
@@ -146,6 +147,16 @@ namespace Emby.Server.Implementations.LiveTv.Listings
}
}
+ private string GetTempFolderPath(Stream stream)
+ {
+#pragma warning disable CA5351
+ using var md5 = MD5.Create();
+#pragma warning restore CA5351
+ var checksum = Convert.ToHexString(md5.ComputeHash(stream));
+ stream.Position = 0;
+ return Path.Combine(_config.ApplicationPaths.TempDirectory, checksum);
+ }
+
private string FindXmlFile(string directory)
{
return _fileSystem.GetFiles(directory, true)