From 3994bedba05bbf116def6161f28d55fda1b5fd5b Mon Sep 17 00:00:00 2001 From: blissful Date: Wed, 11 Oct 2023 20:17:40 -0400 Subject: [PATCH] fix bugs lol --- rose/cache.py | 13 ++++++++++--- setup.py | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/rose/cache.py b/rose/cache.py index 420a5f2..bc84879 100644 --- a/rose/cache.py +++ b/rose/cache.py @@ -238,6 +238,8 @@ def update_cache_for_release(c: Config, release_dir: Path) -> None: virtual_dirname += " [" + ";".join(tags.genre) + "]" if tags.label: virtual_dirname += " {" + ";".join(tags.label) + "}" + if stored_release_data.new: + virtual_dirname += " +NEW!+" virtual_dirname = sanitize_filename(virtual_dirname) # And in case of a name collision, add an extra number at the end. Iterate to find # the first unused number. @@ -354,7 +356,11 @@ def update_cache_for_release(c: Config, release_dir: Path) -> None: filepath = Path(f.path) # Track ID is transient with the cache; we don't put it in any persistent stores. - track_id = str(uuid6.uuid7()) + cursor = conn.execute( + "SELECT id FROM tracks WHERE release_id = ? AND source_path = ?", + (release.id, str(filepath)), + ) + track_id = row["id"] if (row := cursor.fetchone()) else str(uuid6.uuid7()) virtual_filename = "" if multidisc and tags.disc_number: @@ -375,10 +381,11 @@ def update_cache_for_release(c: Config, release_dir: Path) -> None: cursor = conn.execute( """ SELECT EXISTS( - SELECT * FROM tracks WHERE virtual_filename = ? AND id <> ? + SELECT * FROM tracks + WHERE virtual_filename = ? AND release_id = ? AND id <> ? ) """, - (virtual_filename, track_id), + (virtual_filename, release.id, track_id), ) if not cursor.fetchone()[0]: break diff --git a/setup.py b/setup.py index 0a32b05..53ca894 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ license="Apache-2.0", entry_points={"console_scripts": ["rose = rose.__main__:cli"]}, packages=setuptools.find_namespace_packages(where="."), + package_data={"rose": ["*.sql"]}, install_requires=[ "click", "fuse-python",