[utils] Add commit option to the dedupper

This commit is contained in:
2025-02-17 17:36:43 -05:00
parent e08db5e3ad
commit e2b0decd83

View File

@ -272,7 +272,7 @@ def get_file_md5_hash(file_path: str) -> str:
return file_hash.hexdigest()
def deduplicate_tracks():
def deduplicate_tracks(commit=False):
from music.models import Track
# TODO This whole thing should iterate over users
@ -287,9 +287,10 @@ def deduplicate_tracks():
first = tracks.first()
for other in tracks.exclude(id=first.id):
print("moving scrobbles for ", other.id, " to ", first.id)
other.scrobble_set.update(track=first)
print("deleting ", other.id, " - ", other)
other.delete()
if commit:
other.scrobble_set.update(track=first)
print("deleting ", other.id, " - ", other)
other.delete()
def send_notifications_for_scrobble(scrobble_id):