Parcourir la source

[utils] Add commit option to the dedupper

Colin Powell il y a 2 mois
Parent
commit
e2b0decd83
1 fichiers modifiés avec 5 ajouts et 4 suppressions
  1. 5 4
      vrobbler/apps/scrobbles/utils.py

+ 5 - 4
vrobbler/apps/scrobbles/utils.py

@@ -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):