aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Channels/ChannelManager.cs17
-rw-r--r--Emby.Server.Implementations/Security/MBLicenseFile.cs12
2 files changed, 24 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs
index 94ff7c342..0df916ded 100644
--- a/Emby.Server.Implementations/Channels/ChannelManager.cs
+++ b/Emby.Server.Implementations/Channels/ChannelManager.cs
@@ -1108,7 +1108,11 @@ namespace Emby.Server.Implementations.Channels
{
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
{
- return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
+ var cachedResult = _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
+ if (cachedResult != null)
+ {
+ return cachedResult;
+ }
}
}
}
@@ -1131,7 +1135,11 @@ namespace Emby.Server.Implementations.Channels
{
if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
{
- return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
+ var cachedResult = _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath);
+ if (cachedResult != null)
+ {
+ return cachedResult;
+ }
}
}
}
@@ -1162,6 +1170,11 @@ namespace Emby.Server.Implementations.Channels
var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false);
+ if (result == null)
+ {
+ throw new InvalidOperationException("Channel returned a null result from GetChannelItems");
+ }
+
if (!startIndex.HasValue && !limit.HasValue)
{
CacheResponse(result, cachePath);
diff --git a/Emby.Server.Implementations/Security/MBLicenseFile.cs b/Emby.Server.Implementations/Security/MBLicenseFile.cs
index 4b6a82b6c..76741bdf8 100644
--- a/Emby.Server.Implementations/Security/MBLicenseFile.cs
+++ b/Emby.Server.Implementations/Security/MBLicenseFile.cs
@@ -57,9 +57,14 @@ namespace Emby.Server.Implementations.Security
_updateRecords.AddOrUpdate(key, value, (k, v) => value);
}
+ private Guid GetKey(string featureId)
+ {
+ return new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId)));
+ }
+
public void AddRegCheck(string featureId)
{
- var key = new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId)));
+ var key = GetKey(featureId);
var value = DateTime.UtcNow;
SetUpdateRecord(key, value);
@@ -68,7 +73,7 @@ namespace Emby.Server.Implementations.Security
public void RemoveRegCheck(string featureId)
{
- var key = new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId)));
+ var key = GetKey(featureId);
DateTime val;
_updateRecords.TryRemove(key, out val);
@@ -78,8 +83,9 @@ namespace Emby.Server.Implementations.Security
public DateTime LastChecked(string featureId)
{
+ var key = GetKey(featureId);
DateTime last;
- _updateRecords.TryGetValue(new Guid(_cryptographyProvider.ComputeMD5(Encoding.Unicode.GetBytes(featureId))), out last);
+ _updateRecords.TryGetValue(key, out last);
// guard agains people just putting a large number in the file
return last < DateTime.UtcNow ? last : DateTime.MinValue;