mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 13:03:02 +00:00
fix: remove favorite tracks whose values are None when getting favs
+ sync is_fav state when populating
This commit is contained in:
+19
-4
@@ -4,6 +4,7 @@ Helper functions for use with the SQLite database.
|
||||
|
||||
import sqlite3
|
||||
from sqlite3 import Connection, Cursor
|
||||
import time
|
||||
|
||||
from app.models import Album, Playlist, Track
|
||||
from app.settings import APP_DB_PATH, USERDATA_DB_PATH
|
||||
@@ -82,12 +83,26 @@ class SQLiteManager:
|
||||
if self.userdata_db:
|
||||
db_path = USERDATA_DB_PATH
|
||||
|
||||
self.conn = sqlite3.connect(db_path)
|
||||
self.conn = sqlite3.connect(
|
||||
db_path,
|
||||
timeout=15,
|
||||
)
|
||||
return self.conn.cursor()
|
||||
|
||||
def __exit__(self, exc_type, exc_value, exc_traceback):
|
||||
if self.conn:
|
||||
self.conn.commit()
|
||||
trial_count = 0
|
||||
|
||||
if self.CLOSE_CONN:
|
||||
self.conn.close()
|
||||
while trial_count < 10:
|
||||
try:
|
||||
self.conn.commit()
|
||||
|
||||
if self.CLOSE_CONN:
|
||||
self.conn.close()
|
||||
|
||||
return
|
||||
except sqlite3.OperationalError:
|
||||
trial_count += 1
|
||||
time.sleep(3)
|
||||
|
||||
self.conn.close()
|
||||
|
||||
+1
-2
@@ -40,7 +40,7 @@ class Store:
|
||||
cls.tracks = list(tdb.get_all_tracks())
|
||||
|
||||
fav_hashes = favdb.get_fav_tracks()
|
||||
fav_hashes = [t[1] for t in fav_hashes]
|
||||
fav_hashes = " ".join([t[1] for t in fav_hashes])
|
||||
|
||||
for track in tqdm(cls.tracks, desc="Loading tracks"):
|
||||
if track.trackhash in fav_hashes:
|
||||
@@ -225,7 +225,6 @@ class Store:
|
||||
|
||||
cls.folders.append(folder)
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_folder(cls, path: str): # type: ignore
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user