diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs b/MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs index dead97959..83b7c0eb0 100644 --- a/MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs +++ b/MediaBrowser.Server.Implementations/Sqlite/SQLiteRepository.cs @@ -143,20 +143,28 @@ namespace MediaBrowser.Server.Implementations.Sqlite { if (dispose) { - Logger.Info("Disposing " + GetType().Name); - try { - // If we're not already flushing, do it now - if (!IsFlushing) - { - Flush(null); - } - - // Don't dispose in the middle of a flush - while (IsFlushing) + if (connection != null) { - Thread.Sleep(50); + // If we're not already flushing, do it now + if (!IsFlushing) + { + Flush(null); + } + + // Don't dispose in the middle of a flush + while (IsFlushing) + { + Thread.Sleep(50); + } + + if (connection.IsOpen()) + { + connection.Close(); + } + + connection.Dispose(); } if (FlushTimer != null) @@ -165,12 +173,6 @@ namespace MediaBrowser.Server.Implementations.Sqlite FlushTimer = null; } - if (connection.IsOpen()) - { - connection.Close(); - } - - connection.Dispose(); } catch (Exception ex) { |
