fix: stores not being populated on track indexing

This commit is contained in:
cwilvx
2024-08-02 19:59:20 +03:00
parent 0463c80070
commit 04946831ce
5 changed files with 56 additions and 27 deletions
+1
View File
@@ -55,3 +55,4 @@
# Bug fixes
- Duplicates on search
- Audio stops on ending
+8 -2
View File
@@ -10,6 +10,7 @@ import PyInstaller.__main__ as bundler
from app import settings
from app.config import UserConfig
from app.db.userdata import UserTable
from app.logger import log
from app.print_help import HELP_MESSAGE
from app.utils.auth import hash_password
@@ -220,7 +221,8 @@ class ProcessArgs:
sys.exit(0)
username = username.strip()
user = authdb.get_user_by_username(username)
# user = authdb.get_user_by_username(username)
user = UserTable.get_by_username(username)
if not user:
print(f"User {username} not found")
@@ -234,6 +236,10 @@ class ProcessArgs:
sys.exit(0)
password = hash_password(password)
user = authdb.update_user({"id": user.id, "password": password})
# user = authdb.update_user({"id": user.id, "password": password})
UserTable.update_one({
"id": user.id,
"password": password
})
sys.exit(0)
+30 -9
View File
@@ -1,23 +1,44 @@
from app.lib.mapstuff import map_album_colors, map_artist_colors, map_favorites, map_scrobble_data
from app.lib.populate import CordinateMedia
from app.lib.tagger import IndexTracks
from app.store.folder import FolderStore
import gc
from time import time
from app.lib.mapstuff import (
map_album_colors,
map_artist_colors,
map_favorites,
map_scrobble_data,
)
from app.lib.populate import CordinateMedia
from app.lib.tagger import IndexTracks
from app.store.albums import AlbumStore
from app.store.artists import ArtistStore
from app.store.folder import FolderStore
from app.store.tracks import TrackStore
from app.utils.threading import background
def load_and_map():
key = str(time())
FolderStore.load_filepaths()
AlbumStore.load_albums(key)
ArtistStore.load_artists(key)
map_scrobble_data()
map_favorites()
map_artist_colors()
map_album_colors()
class IndexEverything:
def __init__(self) -> None:
IndexTracks(instance_key=time())
key = str(time())
TrackStore.load_all_tracks(key)
AlbumStore.load_albums(key)
ArtistStore.load_artists(key)
FolderStore.load_filepaths()
map_scrobble_data()
map_favorites()
map_artist_colors()
map_album_colors()
CordinateMedia(instance_key=str(time()))
gc.collect()
+15 -10
View File
@@ -2,7 +2,14 @@
Prepares the server for use.
"""
from time import time
import uuid
from app.lib.mapstuff import (
map_album_colors,
map_artist_colors,
map_favorites,
map_scrobble_data,
)
from app.setup.files import create_config_dir
from app.setup.sqlite import run_migrations, setup_sqlite
from app.store.albums import AlbumStore
@@ -29,21 +36,19 @@ def run_setup():
setup_sqlite()
run_migrations()
# try:
# load_settings()
# except IndexError:
# # settings table is empty
# pass
def load_into_mem():
"""
Load all tracks, albums, and artists into memory.
"""
# instance_key = get_random_str()
# INFO: Load all tracks, albums, and artists data into memory
key = str(time())
TrackStore.load_all_tracks(get_random_str())
AlbumStore.load_albums('a')
ArtistStore.load_artists('a')
AlbumStore.load_albums(key)
ArtistStore.load_artists(key)
FolderStore.load_filepaths()
map_scrobble_data()
map_favorites()
map_artist_colors()
map_album_colors()
-4
View File
@@ -61,11 +61,7 @@ mimetypes.add_type("application/manifest+json", ".webmanifest")
# Background tasks
@background
def bg_run_setup():
pass
# run_periodic_scans()
IndexEverything()
# map_scrobble_data()
# map_favorites()
# @background