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; }