(Hopefully) fix concurrency exceptions.
This commit is contained in:
parent
fc02157b42
commit
d0e2027b05
|
@ -29,6 +29,7 @@ using MediaBrowser.Model.Library;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using MediaBrowser.Model.Session;
|
using MediaBrowser.Model.Session;
|
||||||
using MediaBrowser.Model.SyncPlay;
|
using MediaBrowser.Model.SyncPlay;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Episode = MediaBrowser.Controller.Entities.TV.Episode;
|
using Episode = MediaBrowser.Controller.Entities.TV.Episode;
|
||||||
|
|
||||||
|
@ -285,12 +286,19 @@ namespace Emby.Server.Implementations.Session
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue;
|
var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue;
|
||||||
user.LastActivityDate = activityDate;
|
|
||||||
|
|
||||||
if ((activityDate - userLastActivityDate).TotalSeconds > 60)
|
if ((activityDate - userLastActivityDate).TotalSeconds > 60)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
user.LastActivityDate = activityDate;
|
||||||
_userManager.UpdateUser(user);
|
_userManager.UpdateUser(user);
|
||||||
}
|
}
|
||||||
|
catch (DbUpdateConcurrencyException e)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(e, "Error updating user's last activity date.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((activityDate - lastActivityDate).TotalSeconds > 10)
|
if ((activityDate - lastActivityDate).TotalSeconds > 10)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user