Process albums and images during rescue mode, too.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 25 Sep 2011 17:21:03 +0000 (19:21 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 25 Sep 2011 17:21:03 +0000 (19:21 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java

index ad96ab0..8aac5d7 100644 (file)
@@ -1223,6 +1223,22 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                                        }
                                }
                        }
+                       synchronized (albums) {
+                               synchronized (images) {
+                                       for (Album album : storedSone.getAlbums()) {
+                                               albums.remove(album.getId());
+                                               for (Image image : album.getImages()) {
+                                                       images.remove(image.getId());
+                                               }
+                                       }
+                                       for (Album album : sone.getAlbums()) {
+                                               albums.put(album.getId(), album);
+                                               for (Image image : album.getImages()) {
+                                                       images.put(image.getId(), image);
+                                               }
+                                       }
+                               }
+                       }
                        synchronized (storedSone) {
                                if (!soneRescueMode || (sone.getTime() > storedSone.getTime())) {
                                        storedSone.setTime(sone.getTime());
@@ -1242,6 +1258,9 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                                        for (String likedReplyId : sone.getLikedReplyIds()) {
                                                storedSone.addLikedReplyId(likedReplyId);
                                        }
+                                       for (Album album : sone.getAlbums()) {
+                                               storedSone.addAlbum(album);
+                                       }
                                } else {
                                        storedSone.setPosts(sone.getPosts());
                                        storedSone.setReplies(sone.getReplies());