mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Some memory management improvements
This commit is contained in:
parent
059b083359
commit
6ac9da8bed
30 changed files with 362 additions and 100 deletions
|
@ -18,7 +18,6 @@ namespace Ombi.Store.Context
|
|||
|
||||
_created = true;
|
||||
Database.Migrate();
|
||||
|
||||
}
|
||||
|
||||
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -109,5 +110,24 @@ namespace Ombi.Store.Repository
|
|||
Db.EmbyEpisode.AddRange(content);
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
Db?.Dispose();
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IEmbyContentRepository
|
||||
public interface IEmbyContentRepository : IDisposable
|
||||
{
|
||||
Task<EmbyContent> Add(EmbyContent content);
|
||||
Task AddRange(IEnumerable<EmbyContent> content);
|
||||
|
|
|
@ -8,7 +8,7 @@ using Ombi.Store.Entities;
|
|||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IRepository<T> where T : Entity
|
||||
public interface IRepository<T> : IDisposable where T : Entity
|
||||
{
|
||||
Task<T> Find(object key);
|
||||
IQueryable<T> GetAll();
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface ISettingsRepository
|
||||
public interface ISettingsRepository : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Inserts the specified entity.
|
||||
|
|
|
@ -71,5 +71,27 @@ namespace Ombi.Store.Repository
|
|||
{
|
||||
return source.Include(navigationPropertyPath);
|
||||
}
|
||||
|
||||
|
||||
private bool _disposed;
|
||||
// Protected implementation of Dispose pattern.
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
_ctx?.Dispose();
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -89,5 +89,24 @@ namespace Ombi.Store.Repository
|
|||
{
|
||||
return $"{entity}Json";
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
Db?.Dispose();
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue