diff --git a/src/Ombi.Api/Ombi.Api.csproj b/src/Ombi.Api/Ombi.Api.csproj index e20dd6ccd..c7b905522 100644 --- a/src/Ombi.Api/Ombi.Api.csproj +++ b/src/Ombi.Api/Ombi.Api.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/Ombi.Schedule/IocJobFactory.cs b/src/Ombi.Schedule/IocJobFactory.cs index 83ab5a974..795c1fec5 100644 --- a/src/Ombi.Schedule/IocJobFactory.cs +++ b/src/Ombi.Schedule/IocJobFactory.cs @@ -15,7 +15,7 @@ namespace Ombi.Schedule } public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) { - var scopeFactory = _factory.GetService(); + var scopeFactory = _factory.GetService(); var scope = scopeFactory.CreateScope(); var scopedContainer = scope.ServiceProvider; diff --git a/src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs b/src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs index 2a50b5b38..b10311267 100644 --- a/src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs +++ b/src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs @@ -60,7 +60,7 @@ namespace Ombi.Schedule.Jobs.Lidarr ArtistId = a.artistId, ForeignAlbumId = a.foreignAlbumId, ReleaseDate = a.releaseDate, - TrackCount = a.currentRelease.trackCount, + TrackCount = a.currentRelease?.trackCount ?? 0, Monitored = a.monitored, Title = a.title, PercentOfTracks = a.statistics?.percentOfEpisodes ?? 0m, diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs index 5fcac05cc..3ce7307fe 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs @@ -196,7 +196,7 @@ namespace Ombi.Schedule.Jobs.Plex } contentToAdd.Clear(); } - if (count > 200) + if (count > 30) { await Repo.SaveChangesAsync(); @@ -233,7 +233,7 @@ namespace Ombi.Schedule.Jobs.Plex } contentToAdd.Clear(); } - if (count > 200) + if (count > 30) { await Repo.SaveChangesAsync(); } diff --git a/src/Ombi.Store/Ombi.Store.csproj b/src/Ombi.Store/Ombi.Store.csproj index 8dfcc1c28..dd13d5ea7 100644 --- a/src/Ombi.Store/Ombi.Store.csproj +++ b/src/Ombi.Store/Ombi.Store.csproj @@ -16,6 +16,7 @@ + diff --git a/src/Ombi.Store/Repository/BaseRepository.cs b/src/Ombi.Store/Repository/BaseRepository.cs index 0741a79b6..dabcb72b9 100644 --- a/src/Ombi.Store/Repository/BaseRepository.cs +++ b/src/Ombi.Store/Repository/BaseRepository.cs @@ -3,11 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; +using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Ombi.Helpers; using Ombi.Store.Context; using Ombi.Store.Entities; +using Polly; namespace Ombi.Store.Repository { @@ -83,7 +85,17 @@ namespace Ombi.Store.Repository protected async Task InternalSaveChanges() { - return await _ctx.SaveChangesAsync(); + var policy = Policy + .Handle() + .WaitAndRetryAsync(new[] + { + TimeSpan.FromSeconds(1), + TimeSpan.FromSeconds(2), + TimeSpan.FromSeconds(3) + }); + + var result = await policy.ExecuteAndCaptureAsync(async () => await _ctx.SaveChangesAsync()); + return result.Result; }