Skip to content

Commit

Permalink
fix bugs lol
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed Oct 12, 2023
1 parent a871358 commit 3994bed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions rose/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3994bed

Please sign in to comment.