Merge branch 'develop' of https://github.com/tidusjar/ombi into develop

pull/3016/head
tidusjar 5 years ago
commit e58263ec08

@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Polly" Version="6.1.0" />
<PackageReference Include="Polly" Version="7.1.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
</ItemGroup>

@ -15,7 +15,7 @@ namespace Ombi.Schedule
}
public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
{
var scopeFactory = _factory.GetService<IServiceScopeFactory>();
var scopeFactory = _factory.GetService<IServiceScopeFactory>();
var scope = scopeFactory.CreateScope();
var scopedContainer = scope.ServiceProvider;

@ -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,

@ -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();
}

@ -16,6 +16,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Nito.AsyncEx" Version="5.0.0-pre-05" />
<PackageReference Include="Polly" Version="7.1.0" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="1.1.9" />
</ItemGroup>
<ItemGroup>

@ -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<int> InternalSaveChanges()
{
return await _ctx.SaveChangesAsync();
var policy = Policy
.Handle<SqliteException>()
.WaitAndRetryAsync(new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(2),
TimeSpan.FromSeconds(3)
});
var result = await policy.ExecuteAndCaptureAsync(async () => await _ctx.SaveChangesAsync());
return result.Result;
}

Loading…
Cancel
Save