[banshee] [Services] Always clear temporary playlists



commit a7ed4709e67db1e18f9e6a4aa1d344cf908fcc64
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Jun 2 14:04:33 2010 -0700

    [Services] Always clear temporary playlists
    
    The ClearTemporary methods were assuming that running once per session
    was sufficient, but that's not the case when disabling/enabling the
    Audiobook library extension.

 .../Banshee.Playlist/PlaylistSource.cs             |   16 ++++++----------
 .../Banshee.SmartPlaylist/SmartPlaylistSource.cs   |   16 ++++++----------
 2 files changed, 12 insertions(+), 20 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs b/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
index 3605504..3255f9d 100644
--- a/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
+++ b/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
@@ -359,18 +359,14 @@ namespace Banshee.Playlist
             }
         }
 
-        private static bool temps_cleared = false;
         private static void ClearTemporary ()
         {
-            if (!temps_cleared) {
-                temps_cleared = true;
-                ServiceManager.DbConnection.BeginTransaction ();
-                ServiceManager.DbConnection.Execute (@"
-                    DELETE FROM CorePlaylistEntries WHERE PlaylistID IN (SELECT PlaylistID FROM CorePlaylists WHERE IsTemporary = 1);
-                    DELETE FROM CorePlaylists WHERE IsTemporary = 1;"
-                );
-                ServiceManager.DbConnection.CommitTransaction ();
-            }
+            ServiceManager.DbConnection.BeginTransaction ();
+            ServiceManager.DbConnection.Execute (@"
+                DELETE FROM CorePlaylistEntries WHERE PlaylistID IN (SELECT PlaylistID FROM CorePlaylists WHERE IsTemporary = 1);
+                DELETE FROM CorePlaylists WHERE IsTemporary = 1;"
+            );
+            ServiceManager.DbConnection.CommitTransaction ();
         }
 
         private static int GetPlaylistId (string name)
diff --git a/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs b/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
index 8cd1734..8f8f69e 100644
--- a/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
+++ b/src/Core/Banshee.Services/Banshee.SmartPlaylist/SmartPlaylistSource.cs
@@ -513,18 +513,14 @@ namespace Banshee.SmartPlaylist
             }
         }
 
-        private static bool temps_cleared = false;
         private static void ClearTemporary ()
         {
-            if (!temps_cleared) {
-                temps_cleared = true;
-                ServiceManager.DbConnection.Execute (@"
-                    BEGIN TRANSACTION;
-                        DELETE FROM CoreSmartPlaylistEntries WHERE SmartPlaylistID IN (SELECT SmartPlaylistID FROM CoreSmartPlaylists WHERE IsTemporary = 1);
-                        DELETE FROM CoreSmartPlaylists WHERE IsTemporary = 1;
-                    COMMIT TRANSACTION"
-                );
-            }
+            ServiceManager.DbConnection.Execute (@"
+                BEGIN TRANSACTION;
+                    DELETE FROM CoreSmartPlaylistEntries WHERE SmartPlaylistID IN (SELECT SmartPlaylistID FROM CoreSmartPlaylists WHERE IsTemporary = 1);
+                    DELETE FROM CoreSmartPlaylists WHERE IsTemporary = 1;
+                COMMIT TRANSACTION"
+            );
         }
 
         private static void HandleSourceAdded (SourceEventArgs args)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]