From: David ‘Bombe’ Roden Date: Tue, 22 Oct 2013 06:10:32 +0000 (+0200) Subject: Store all albums. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b82686b3fcccf5c784eccd9411d541aa995448d0;p=Sone.git Store all albums. --- diff --git a/src/main/java/net/pterodactylus/sone/data/impl/DefaultAlbumBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/DefaultAlbumBuilder.java index fd4b5a5..a2f198f 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/DefaultAlbumBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/DefaultAlbumBuilder.java @@ -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; } diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java index 8817016..e311a5e 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -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(); }