aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-08-10 18:13:17 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-08-10 18:13:17 -0400
commite84ba17b9f48a3bc8811b1a89c54c25bc6607599 (patch)
tree220ce22658497f75f4d575296fc903cd19a60339 /MediaBrowser.Server.Implementations/Sync/SyncRepository.cs
parent0f508dab47ebcc27d973840d03025f28f52a14b6 (diff)
add activity log feature
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sync/SyncRepository.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Sync/SyncRepository.cs46
1 files changed, 44 insertions, 2 deletions
diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs
index bb22e992b..65da74f9e 100644
--- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs
+++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.Sync
{
- public class SyncRepository : ISyncRepository
+ public class SyncRepository : ISyncRepository, IDisposable
{
private IDbConnection _connection;
private readonly ILogger _logger;
@@ -422,8 +422,50 @@ namespace MediaBrowser.Server.Implementations.Sync
}
info.TargetId = reader.GetString(5);
-
+
return info;
}
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private readonly object _disposeLock = new object();
+
+ /// <summary>
+ /// Releases unmanaged and - optionally - managed resources.
+ /// </summary>
+ /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
+ protected virtual void Dispose(bool dispose)
+ {
+ if (dispose)
+ {
+ try
+ {
+ lock (_disposeLock)
+ {
+ if (_connection != null)
+ {
+ if (_connection.IsOpen())
+ {
+ _connection.Close();
+ }
+
+ _connection.Dispose();
+ _connection = null;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("Error disposing database", ex);
+ }
+ }
+ }
}
}