Store all albums.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 22 Oct 2013 06:10:32 +0000 (08:10 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:33 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/data/impl/DefaultAlbumBuilder.java
src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java

index fd4b5a5..a2f198f 100644 (file)
@@ -44,9 +44,7 @@ public class DefaultAlbumBuilder extends AbstractAlbumBuilder {
        public Album build() throws IllegalStateException {
                validate();
                DefaultAlbum album = new DefaultAlbum(database, getId(), sone, parentId);
-               if (parentId != null) {
-                       database.storeAlbum(album);
-               }
+               database.storeAlbum(album);
                return album;
        }
 
index 8817016..e311a5e 100644 (file)
@@ -536,7 +536,9 @@ public class MemoryDatabase extends AbstractService implements Database {
                lock.writeLock().lock();
                try {
                        allAlbums.put(album.getId(), album);
-                       albumChildren.put(album.getParent().getId(), album.getId());
+                       if (!album.isRoot()) {
+                               albumChildren.put(album.getParent().getId(), album.getId());
+                       }
                } finally {
                        lock.writeLock().unlock();
                }