mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
feat: support watching symlinks in watchdogg.py
+ remove code for auto-adding ~/Home to root_dirs during populate
This commit is contained in:
+5
-2
@@ -30,8 +30,11 @@ def get_folder_tree():
|
||||
|
||||
root_dirs = db.get_root_dirs()
|
||||
|
||||
if req_dir == "$home" and root_dirs[0] == "$home":
|
||||
req_dir = settings.USER_HOME_DIR
|
||||
try:
|
||||
if req_dir == "$home" and root_dirs[0] == "$home":
|
||||
req_dir = settings.USER_HOME_DIR
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
if req_dir == "$home":
|
||||
folders = [Path(f) for f in root_dirs]
|
||||
|
||||
+15
-9
@@ -1,12 +1,13 @@
|
||||
from flask import Blueprint, request
|
||||
from app import settings
|
||||
|
||||
from app.db.sqlite.settings import SettingsSQLMethods as sdb
|
||||
from app.lib import populate
|
||||
from app.logger import log
|
||||
|
||||
from app.logger import log
|
||||
from app.lib import populate
|
||||
from app.db.store import Store
|
||||
from app.utils import background
|
||||
from app.lib.watchdogg import Watcher as WatchDog
|
||||
from app.db.sqlite.settings import SettingsSQLMethods as sdb
|
||||
|
||||
api = Blueprint("settings", __name__, url_prefix="/")
|
||||
|
||||
@@ -19,6 +20,10 @@ def get_child_dirs(parent: str, children: list[str]):
|
||||
|
||||
@background
|
||||
def rebuild_store(db_dirs: list[str]):
|
||||
"""
|
||||
Restarts the watchdog and rebuilds the music library.
|
||||
"""
|
||||
|
||||
log.info("Rebuilding library...")
|
||||
Store.remove_tracks_by_dir_except(db_dirs)
|
||||
|
||||
@@ -28,6 +33,7 @@ def rebuild_store(db_dirs: list[str]):
|
||||
Store.load_artists()
|
||||
|
||||
populate.Populate()
|
||||
WatchDog().restart()
|
||||
|
||||
log.info("Rebuilding library... ✅")
|
||||
|
||||
@@ -59,13 +65,13 @@ def add_root_dirs():
|
||||
db_dirs = sdb.get_root_dirs()
|
||||
_h = "$home"
|
||||
|
||||
if db_dirs[0] == _h and new_dirs[0] == _h.strip():
|
||||
return {"msg": "Not changed!"}
|
||||
|
||||
if db_dirs[0] == _h:
|
||||
sdb.remove_root_dirs(db_dirs)
|
||||
|
||||
try:
|
||||
if db_dirs[0] == _h and new_dirs[0] == _h.strip():
|
||||
return {"msg": "Not changed!"}
|
||||
|
||||
if db_dirs[0] == _h:
|
||||
sdb.remove_root_dirs(db_dirs)
|
||||
|
||||
if new_dirs[0] == _h:
|
||||
finalize([_h], db_dirs, [settings.USER_HOME_DIR])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user