9
9
from tauon .t_modules .t_extra import RadioPlaylist , RadioStation , TauonPlaylist , TauonQueueItem
10
10
11
11
if TYPE_CHECKING :
12
- from tauon .t_modules .t_main import GuiVar , Prefs , StarStore , Tauon , TrackClass
12
+ from tauon .t_modules .t_main import GuiVar , Prefs , StarRecord , StarStore , Tauon , TrackClass
13
13
14
14
15
15
def database_migrate (
@@ -18,7 +18,7 @@ def database_migrate(
18
18
db_version : float ,
19
19
master_library : dict [int , TrackClass ],
20
20
install_mode : bool ,
21
- multi_playlist : list | list [TauonPlaylist ],
21
+ multi_playlist : list [ str | int | bool ] | list [TauonPlaylist ],
22
22
star_store : StarStore ,
23
23
a_cache_dir : str ,
24
24
cache_directory : Path ,
@@ -29,7 +29,7 @@ def database_migrate(
29
29
gen_codes : dict [int , str ],
30
30
prefs : Prefs ,
31
31
radio_playlists : list [dict [str , int | str | list [dict [str , str ]]]] | list [RadioPlaylist ],
32
- p_force_queue : list | list [TauonQueueItem ],
32
+ p_force_queue : list [ int | bool ] | list [TauonQueueItem ],
33
33
theme : int ,
34
34
) -> tuple [
35
35
dict [int , TrackClass ],
@@ -545,7 +545,7 @@ def database_migrate(
545
545
p_force_queue = new_queue
546
546
547
547
if db_version <= 69 :
548
- logging .info ("Updating database to version 69 " )
548
+ logging .info ("Updating database to version 70 " )
549
549
new_radio_playlists : list [RadioPlaylist ] = []
550
550
for playlist in radio_playlists :
551
551
stations : list [RadioStation ] = []
@@ -567,5 +567,20 @@ def database_migrate(
567
567
stations = stations ))
568
568
radio_playlists = new_radio_playlists
569
569
570
+ if db_version <= 70 :
571
+ logging .info ("Updating database to version 71" )
572
+ new_starstore_db : dict [tuple [str , str , str ], StarRecord ] = {}
573
+ old_record : list [int | str ] = [] # Here just for typing
574
+ for key , old_record in star_store .db .items ():
575
+ new_record = star_store .new_object ()
576
+ new_record .playtime = old_record [0 ]
577
+ new_record .loved = "L" in old_record [1 ]
578
+ new_record .rating = old_record [2 ]
579
+ # There was a bug where the fourth element was not set
580
+ if len (old_record ) == 4 :
581
+ new_record .loved_timestamp = old_record [3 ]
582
+ new_starstore_db [key ] = new_record
583
+
584
+ star_store .db = new_starstore_db
570
585
571
586
return master_library , multi_playlist , star_store , p_force_queue , theme , prefs , gui , gen_codes , radio_playlists
0 commit comments