| | | 1 | | using System; |
| | | 2 | | using System.Threading.Tasks; |
| | | 3 | | using Microsoft.EntityFrameworkCore; |
| | | 4 | | using Microsoft.Extensions.Logging; |
| | | 5 | | |
| | | 6 | | namespace Jellyfin.Database.Implementations.Locking; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Default lock behavior. Defines no explicit application locking behavior. |
| | | 10 | | /// </summary> |
| | | 11 | | public class NoLockBehavior : IEntityFrameworkCoreLockingBehavior |
| | | 12 | | { |
| | | 13 | | private readonly ILogger<NoLockBehavior> _logger; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Initializes a new instance of the <see cref="NoLockBehavior"/> class. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="logger">The Application logger.</param> |
| | | 19 | | public NoLockBehavior(ILogger<NoLockBehavior> logger) |
| | | 20 | | { |
| | 43 | 21 | | _logger = logger; |
| | 43 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <inheritdoc/> |
| | | 25 | | public void OnSaveChanges(JellyfinDbContext context, Action saveChanges) |
| | | 26 | | { |
| | 466 | 27 | | saveChanges(); |
| | 466 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <inheritdoc/> |
| | | 31 | | public void Initialise(DbContextOptionsBuilder optionsBuilder) |
| | | 32 | | { |
| | 42 | 33 | | _logger.LogInformation("The database locking mode has been set to: NoLock."); |
| | 42 | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <inheritdoc/> |
| | | 37 | | public async Task OnSaveChangesAsync(JellyfinDbContext context, Func<Task> saveChanges) |
| | | 38 | | { |
| | | 39 | | await saveChanges().ConfigureAwait(false); |
| | | 40 | | } |
| | | 41 | | } |