diff --git a/rose/cache.py b/rose/cache.py index 271fbbb..e268a73 100644 --- a/rose/cache.py +++ b/rose/cache.py @@ -634,7 +634,9 @@ def _update_cache_for_releases_executor( # Handle cover art change. try: cover = next( - Path(f).resolve() for f in files if os.path.basename(f).lower() in c.valid_art_exts + Path(f).resolve() + for f in files + if os.path.basename(f).lower() in c.valid_cover_arts ) except StopIteration: # No cover art in directory. cover = None diff --git a/rose/collages.py b/rose/collages.py index 27a5617..04b9462 100644 --- a/rose/collages.py +++ b/rose/collages.py @@ -95,8 +95,12 @@ def remove_release_from_collage( with lock(c, collage_lock_name(collage_name)): with path.open("rb") as fp: data = tomllib.load(fp) - data["releases"] = data.get("releases", []) - data["releases"] = [r for r in data.get("releases", []) if r["uuid"] != release_id] + old_releases = data.get("releases", []) + new_releases = [r for r in old_releases if r["uuid"] != release_id] + if old_releases == new_releases: + logger.info(f"No-Op: Release {release_dirname} not in collage {collage_name}") + return + data["releases"] = new_releases with path.open("wb") as fp: tomli_w.dump(data, fp) logger.info(f"Removed release {release_dirname} from collage {collage_name}") @@ -120,9 +124,7 @@ def add_release_to_collage( # duplicate collage entries. for r in data["releases"]: if r["uuid"] == release_id: - logger.debug( - f"No-Opping: Release {release_dirname} already in collage {collage_name}" - ) + logger.info(f"No-Op: Release {release_dirname} already in collage {collage_name}") return data["releases"].append({"uuid": release_id, "description_meta": release_dirname}) with path.open("wb") as fp: diff --git a/rose/playlists.py b/rose/playlists.py index 4e97224..9b960aa 100644 --- a/rose/playlists.py +++ b/rose/playlists.py @@ -96,8 +96,12 @@ def remove_track_from_playlist( with lock(c, playlist_lock_name(playlist_name)): with path.open("rb") as fp: data = tomllib.load(fp) - data["tracks"] = data.get("tracks", []) - data["tracks"] = [r for r in data.get("tracks", []) if r["uuid"] != track_id] + old_tracks = data.get("tracks", []) + new_tracks = [r for r in old_tracks if r["uuid"] != track_id] + if old_tracks == new_tracks: + logger.info(f"No-Op: track {track_filename} not in playlist {playlist_name}") + return + data["tracks"] = new_tracks with path.open("wb") as fp: tomli_w.dump(data, fp) logger.info(f"Removed track {track_filename} from playlist {playlist_name}") @@ -121,9 +125,7 @@ def add_track_to_playlist( # duplicate playlist entries. for r in data["tracks"]: if r["uuid"] == track_id: - logger.debug( - f"No-Opping: Track {track_filename} already in playlist {playlist_name}" - ) + logger.info(f"No-Op: Track {track_filename} already in playlist {playlist_name}") return data["tracks"].append({"uuid": track_id, "description_meta": track_filename}) with path.open("wb") as fp: diff --git a/rose/releases.py b/rose/releases.py index 3f3e190..d3c1834 100644 --- a/rose/releases.py +++ b/rose/releases.py @@ -182,6 +182,12 @@ def from_toml(cls, toml: str) -> MetadataRelease: def edit_release(c: Config, release_id_or_virtual_dirname: str) -> None: release_id, _ = resolve_release_ids(c, release_id_or_virtual_dirname) + + # Trigger a quick cache update to ensure we are reading the liveliest data. + source_path = get_release_source_path_from_id(c, release_id) + assert source_path is not None + update_cache_for_releases(c, [source_path]) + with lock(c, release_lock_name(release_id)): cachedata = get_release(c, release_id_or_virtual_dirname) if not cachedata: