Windows
This commit is contained in:
@@ -127,15 +127,30 @@ class LibraryWatcher:
|
||||
self._full_scan_all()
|
||||
return
|
||||
|
||||
self._observer = Observer()
|
||||
libraries = get_libraries(active_only=True)
|
||||
import sqlite3
|
||||
from local.local_db import DB_PATH
|
||||
conn = sqlite3.connect(str(DB_PATH))
|
||||
conn.row_factory = sqlite3.Row
|
||||
libraries = conn.execute(
|
||||
"SELECT id, path FROM libraries WHERE is_active=1"
|
||||
).fetchall()
|
||||
conn.close()
|
||||
|
||||
if not libraries:
|
||||
logger.info("Ingen biblioteker — springer watchdog over")
|
||||
self._running = True
|
||||
return
|
||||
|
||||
# Brug længere poll-interval på Windows for at spare handles
|
||||
import sys
|
||||
poll_interval = 30 if sys.platform == "win32" else 5
|
||||
self._observer = Observer(timeout=poll_interval)
|
||||
|
||||
for lib in libraries:
|
||||
path = Path(lib["path"])
|
||||
if not path.exists():
|
||||
logger.warning(f"Bibliotek findes ikke: {path}")
|
||||
continue
|
||||
|
||||
handler = MusicLibraryHandler(lib["id"], self.on_change)
|
||||
self._observer.schedule(handler, str(path), recursive=True)
|
||||
logger.info(f"Overvåger: {path}")
|
||||
|
||||
Reference in New Issue
Block a user