More memory management and improvements

This commit is contained in:
tidusjar 2018-01-09 21:16:06 +00:00
commit 96cf4388bc
12 changed files with 128 additions and 7 deletions

View file

@ -102,5 +102,25 @@ namespace Ombi.Schedule.Jobs.Couchpotato
throw; throw;
} }
} }
private bool _disposed;
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_settings?.Dispose();
_ctx?.Dispose();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
} }
} }

View file

@ -2,7 +2,7 @@
namespace Ombi.Schedule.Jobs.Couchpotato namespace Ombi.Schedule.Jobs.Couchpotato
{ {
public interface ICouchPotatoSync public interface ICouchPotatoSync : IBaseJob
{ {
Task Start(); Task Start();
} }

View file

@ -3,7 +3,7 @@ using Hangfire.Server;
namespace Ombi.Schedule.Jobs.Ombi namespace Ombi.Schedule.Jobs.Ombi
{ {
public interface IOmbiAutomaticUpdater public interface IOmbiAutomaticUpdater : IBaseJob
{ {
Task Update(PerformContext context); Task Update(PerformContext context);
string[] GetVersion(); string[] GetVersion();

View file

@ -3,7 +3,7 @@ using Ombi.Store.Entities;
namespace Ombi.Schedule.Jobs.Ombi namespace Ombi.Schedule.Jobs.Ombi
{ {
public interface IWelcomeEmail public interface IWelcomeEmail : IBaseJob
{ {
Task SendEmail(OmbiUser user); Task SendEmail(OmbiUser user);
} }

View file

@ -315,5 +315,25 @@ namespace Ombi.Schedule.Jobs.Ombi
await client.DownloadFileTaskAsync(requestUri, filename); await client.DownloadFileTaskAsync(requestUri, filename);
} }
} }
private bool _disposed;
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_appConfig?.Dispose();
Settings?.Dispose();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
} }
} }

View file

@ -1,4 +1,5 @@
using System.Threading.Tasks; using System;
using System.Threading.Tasks;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Notifications; using Ombi.Notifications;
@ -62,5 +63,25 @@ namespace Ombi.Schedule.Jobs.Ombi
return parsed; return parsed;
} }
private bool _disposed;
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_emailSettings?.Dispose();
_customizationSettings?.Dispose();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
} }
} }

View file

@ -4,7 +4,7 @@ using Ombi.Store.Entities;
namespace Ombi.Schedule.Jobs.Radarr namespace Ombi.Schedule.Jobs.Radarr
{ {
public interface IRadarrSync public interface IRadarrSync : IBaseJob
{ {
Task CacheContent(); Task CacheContent();
Task<IEnumerable<RadarrCache>> GetCachedContent(); Task<IEnumerable<RadarrCache>> GetCachedContent();

View file

@ -89,5 +89,25 @@ namespace Ombi.Schedule.Jobs.Radarr
{ {
return await _ctx.RadarrCache.ToListAsync(); return await _ctx.RadarrCache.ToListAsync();
} }
private bool _disposed;
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_ctx?.Dispose();
RadarrSettings?.Dispose();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
} }
} }

View file

@ -2,7 +2,7 @@
namespace Ombi.Schedule.Jobs.SickRage namespace Ombi.Schedule.Jobs.SickRage
{ {
public interface ISickRageSync public interface ISickRageSync : IBaseJob
{ {
Task Start(); Task Start();
} }

View file

@ -88,5 +88,25 @@ namespace Ombi.Schedule.Jobs.SickRage
SemaphoreSlim.Release(); SemaphoreSlim.Release();
} }
} }
private bool _disposed;
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_settings?.Dispose();
_ctx?.Dispose();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
} }
} }

View file

@ -2,7 +2,7 @@
namespace Ombi.Schedule.Jobs.Sonarr namespace Ombi.Schedule.Jobs.Sonarr
{ {
public interface ISonarrSync public interface ISonarrSync : IBaseJob
{ {
Task Start(); Task Start();
} }

View file

@ -84,5 +84,25 @@ namespace Ombi.Schedule.Jobs.Sonarr
SemaphoreSlim.Release(); SemaphoreSlim.Release();
} }
} }
private bool _disposed;
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_settings?.Dispose();
_ctx?.Dispose();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
} }
} }