Load artist database and log loaded tag count at startup
Browse files
app.py
CHANGED
|
@@ -361,20 +361,34 @@ def copy_artist_database():
|
|
| 361 |
for path in (
|
| 362 |
DATA_MOUNT / "_cache" / "artists.sqlite",
|
| 363 |
DATA_DIR / "_cache" / "artists.sqlite",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
DATA_MOUNT / "artists.sqlite",
|
| 365 |
DATA_DIR / "artists.sqlite",
|
|
|
|
|
|
|
| 366 |
Path.cwd() / "artists.sqlite",
|
|
|
|
| 367 |
)
|
| 368 |
if path.is_file()
|
| 369 |
),
|
| 370 |
None,
|
| 371 |
)
|
| 372 |
if source is None:
|
|
|
|
| 373 |
return
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
|
| 379 |
|
| 380 |
def cleanup_mount():
|
|
|
|
| 361 |
for path in (
|
| 362 |
DATA_MOUNT / "_cache" / "artists.sqlite",
|
| 363 |
DATA_DIR / "_cache" / "artists.sqlite",
|
| 364 |
+
Path("_cache/artists.sqlite"),
|
| 365 |
+
Path.cwd() / "_cache" / "artists.sqlite",
|
| 366 |
+
Path.cwd().parent / "_cache" / "artists.sqlite",
|
| 367 |
+
Path.cwd().parent / "data" / "_cache" / "artists.sqlite",
|
| 368 |
DATA_MOUNT / "artists.sqlite",
|
| 369 |
DATA_DIR / "artists.sqlite",
|
| 370 |
+
Path("artists.sqlite"),
|
| 371 |
+
Path("../artists.sqlite"),
|
| 372 |
Path.cwd() / "artists.sqlite",
|
| 373 |
+
Path.cwd().parent / "artists.sqlite",
|
| 374 |
)
|
| 375 |
if path.is_file()
|
| 376 |
),
|
| 377 |
None,
|
| 378 |
)
|
| 379 |
if source is None:
|
| 380 |
+
log("Cannot find artist database")
|
| 381 |
return
|
| 382 |
+
if source.resolve() != ARTIST_DB.resolve():
|
| 383 |
+
temp = ARTIST_DB.with_suffix(".sqlite.part")
|
| 384 |
+
shutil.copy2(source, temp)
|
| 385 |
+
temp.replace(ARTIST_DB)
|
| 386 |
+
try:
|
| 387 |
+
with sqlite3.connect(ARTIST_DB) as database:
|
| 388 |
+
count = database.execute("SELECT count(*) FROM artists").fetchone()[0]
|
| 389 |
+
log(f"Found artist database: {count} tags loaded")
|
| 390 |
+
except Exception:
|
| 391 |
+
log("Cannot find artist database")
|
| 392 |
|
| 393 |
|
| 394 |
def cleanup_mount():
|