From f1d43fb2a93dfb7a2c0bf217d471c396e53256a8 Mon Sep 17 00:00:00 2001 From: blissful Date: Wed, 11 Oct 2023 20:17:40 -0400 Subject: [PATCH] fix bugs lol --- pyproject.toml | 1 + rose/cache.py | 13 ++++++++++--- setup.py | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9a26b6b..fcfce0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,7 @@ addopts = [ "--cov=.", "--cov-branch", "--import-mode=importlib", + "--ignore=result", ] pythonpath = "." python_files = ["*_test.py", "__test__.py"] 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",