From b82686b3fcccf5c784eccd9411d541aa995448d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 22 Oct 2013 08:10:32 +0200 Subject: [PATCH] Store all albums. --- .../java/net/pterodactylus/sone/data/impl/DefaultAlbumBuilder.java | 4 +--- .../java/net/pterodactylus/sone/database/memory/MemoryDatabase.java | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) 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(); } -- 2.7.4