From 356a84e5ec2bb0936b7d1cdc635f7f051788da6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Apr 2011 06:53:37 +0200 Subject: [PATCH] Remove image from previous album, if set. --- src/main/java/net/pterodactylus/sone/data/Album.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index e3b33de..20862a4 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -160,6 +160,9 @@ public class Album implements Fingerprintable { */ public void addImage(Image image) { Validation.begin().isNotNull("Image", image).check().isNotNull("Image Owner", image.getSone()).check().isEqual("Image Owner", image.getSone(), sone).check(); + if (image.getAlbum() != null) { + image.getAlbum().removeImage(image); + } image.setAlbum(this); if (!images.contains(image)) { images.add(image); -- 2.7.4