Only add an album if it doesn’t yet exist.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Apr 2011 04:53:25 +0000 (06:53 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Apr 2011 04:53:25 +0000 (06:53 +0200)
src/main/java/net/pterodactylus/sone/data/Album.java

index 0abc59c..e3b33de 100644 (file)
@@ -125,8 +125,10 @@ public class Album implements Fingerprintable {
         */
        public void addAlbum(Album album) {
                Validation.begin().isNotNull("Album", album).check().isEqual("Album Owner", album.sone, sone).isEither("Old Album Parent", this.parent, null, album.parent).check();
-               albums.add(album);
                album.setParent(this);
+               if (!albums.contains(album)) {
+                       albums.add(album);
+               }
        }
 
        /**