db struktur
This commit is contained in:
@@ -79,7 +79,7 @@ class LibraryManagerDialog(QDialog):
|
||||
conn = sqlite3.connect(self._db_path)
|
||||
conn.row_factory = sqlite3.Row
|
||||
libs = conn.execute(
|
||||
"SELECT id, path, last_full_scan FROM libraries "
|
||||
"SELECT id, path FROM libraries "
|
||||
"WHERE is_active=1 ORDER BY path"
|
||||
).fetchall()
|
||||
|
||||
@@ -87,15 +87,16 @@ class LibraryManagerDialog(QDialog):
|
||||
bpm_missing = {}
|
||||
for lib in libs:
|
||||
counts[lib["id"]] = conn.execute(
|
||||
"SELECT COUNT(*) FROM songs "
|
||||
"WHERE library_id=? AND file_missing=0",
|
||||
(lib["id"],)
|
||||
"SELECT COUNT(*) FROM files "
|
||||
"WHERE file_missing=0 AND local_path LIKE ?",
|
||||
(lib["path"] + "%",)
|
||||
).fetchone()[0]
|
||||
bpm_missing[lib["id"]] = conn.execute(
|
||||
"SELECT COUNT(*) FROM songs "
|
||||
"WHERE library_id=? AND file_missing=0 "
|
||||
"AND (bpm IS NULL OR bpm=0)",
|
||||
(lib["id"],)
|
||||
"SELECT COUNT(*) FROM files f "
|
||||
"JOIN songs s ON s.id = f.song_id "
|
||||
"WHERE f.file_missing=0 AND f.local_path LIKE ? "
|
||||
"AND (s.bpm IS NULL OR s.bpm=0)",
|
||||
(lib["path"] + "%",)
|
||||
).fetchone()[0]
|
||||
conn.close()
|
||||
|
||||
@@ -122,9 +123,7 @@ class LibraryManagerDialog(QDialog):
|
||||
lib_id = lib["id"]
|
||||
path = lib["path"]
|
||||
exists = Path(path).exists()
|
||||
last = lib.get("last_full_scan") or "aldrig"
|
||||
if isinstance(last, str) and len(last) > 16:
|
||||
last = last[:16]
|
||||
last = "—"
|
||||
|
||||
frame = QFrame()
|
||||
frame.setObjectName("track_display")
|
||||
@@ -246,11 +245,12 @@ class LibraryManagerDialog(QDialog):
|
||||
|
||||
try:
|
||||
conn = sqlite3.connect(self._db_path)
|
||||
# Slet sange fra biblioteket
|
||||
# Marker filer fra denne mappe som missing
|
||||
conn.execute(
|
||||
"DELETE FROM songs WHERE library_id=?", (lib["id"],)
|
||||
"UPDATE files SET file_missing=1 WHERE local_path LIKE ?",
|
||||
(lib["path"] + "%",)
|
||||
)
|
||||
# Slet selve biblioteks-rækken helt
|
||||
# Slet selve biblioteks-rækken
|
||||
conn.execute(
|
||||
"DELETE FROM libraries WHERE id=?", (lib["id"],)
|
||||
)
|
||||
@@ -297,4 +297,4 @@ class LibraryManagerDialog(QDialog):
|
||||
for w in list(self._workers.values()):
|
||||
w.cancel()
|
||||
w.wait(2000) # Vent max 2 sek på at tråden stopper
|
||||
event.accept()
|
||||
event.accept()
|
||||
Reference in New Issue
Block a user