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 f1d43fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ addopts = [
"--cov=.",
"--cov-branch",
"--import-mode=importlib",
"--ignore=result",
]
pythonpath = "."
python_files = ["*_test.py", "__test__.py"]
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 f1d43fb

Please sign in to comment.