[utils] Add commit option to the dedupper
This commit is contained in:
@ -272,7 +272,7 @@ def get_file_md5_hash(file_path: str) -> str:
|
|||||||
return file_hash.hexdigest()
|
return file_hash.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
def deduplicate_tracks():
|
def deduplicate_tracks(commit=False):
|
||||||
from music.models import Track
|
from music.models import Track
|
||||||
|
|
||||||
# TODO This whole thing should iterate over users
|
# TODO This whole thing should iterate over users
|
||||||
@ -287,9 +287,10 @@ def deduplicate_tracks():
|
|||||||
first = tracks.first()
|
first = tracks.first()
|
||||||
for other in tracks.exclude(id=first.id):
|
for other in tracks.exclude(id=first.id):
|
||||||
print("moving scrobbles for ", other.id, " to ", first.id)
|
print("moving scrobbles for ", other.id, " to ", first.id)
|
||||||
other.scrobble_set.update(track=first)
|
if commit:
|
||||||
print("deleting ", other.id, " - ", other)
|
other.scrobble_set.update(track=first)
|
||||||
other.delete()
|
print("deleting ", other.id, " - ", other)
|
||||||
|
other.delete()
|
||||||
|
|
||||||
|
|
||||||
def send_notifications_for_scrobble(scrobble_id):
|
def send_notifications_for_scrobble(scrobble_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user