]> kaliko git repositories - mpd-sima.git/blobdiff - sima/lib/simadb.py
simadb: Expose file in view_bl
[mpd-sima.git] / sima / lib / simadb.py
index 5646a498f4632f4f11f01b346af6beeaa1ed0a3c..0125039bf02c3d3fcb26b77ef17842242be6a659 100644 (file)
@@ -45,8 +45,7 @@ class SimaDB:
 
     def get_database_connection(self):
         """get database reference"""
-        connection = sqlite3.connect(
-            self._db_path, isolation_level=None)
+        connection = sqlite3.connect(self._db_path, isolation_level=None)
         return connection
 
     def get_info(self):
@@ -383,7 +382,8 @@ class SimaDB:
                 connection.close()
             return row[0]
         if not add:  # Not adding non existing track
-            connection.close()
+            if not with_connection:
+                connection.close()
             return None
         # Get an artist record or None
         if track.artist:
@@ -609,6 +609,8 @@ class SimaDB:
             "SELECT id FROM blocklist WHERE track = ?", (track_id,))
         if not rows.fetchone():
             if not add:
+                if not with_connection:
+                    connection.close()
                 return None
             connection.execute('INSERT INTO blocklist (track) VALUES (?)',
                                (track_id,))
@@ -634,6 +636,8 @@ class SimaDB:
             "SELECT id FROM blocklist WHERE album = ?", (album_id,))
         if not rows.fetchone():
             if not add:
+                if not with_connection:
+                    connection.close()
                 return None
             connection.execute('INSERT INTO blocklist (album) VALUES (?)',
                                (album_id,))
@@ -679,6 +683,7 @@ class SimaDB:
                albums.mbid AS musicbrainz_album,
                tracks.title AS title,
                tracks.mbid AS musicbrainz_title,
+               tracks.file AS file,
                blocklist.id
                FROM blocklist
                LEFT OUTER JOIN artists ON blocklist.artist = artists.id