From 4b8ef3b63222f792f32d7fdb623b7baf66f076ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 15 Sep 2014 18:25:07 +0200 Subject: [PATCH] Store parsed images locally only, get avatar from local images. --- src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java index e5ffaf9..a46d911 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java @@ -24,8 +24,10 @@ import static java.util.concurrent.TimeUnit.DAYS; import java.io.InputStream; import java.net.MalformedURLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -477,6 +479,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade /* parse albums. */ SimpleXML albumsXml = soneXml.getNode("albums"); + Map allImages = new HashMap(); List topLevelAlbums = new ArrayList(); if (albumsXml != null) { for (SimpleXML albumXml : albumsXml.getNodes("album")) { @@ -535,6 +538,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade image = image.modify().setTitle(imageTitle).setDescription(imageDescription).update(); image = image.modify().setWidth(imageWidth).setHeight(imageHeight).update(); album.addImage(image); + allImages.put(imageId, image); } } album.modify().setAlbumImage(albumImageId).update(); @@ -543,7 +547,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade /* process avatar. */ if (avatarId != null) { - profile.setAvatar(core.getImage(avatarId, false)); + profile.setAvatar(allImages.get(avatarId)); } /* okay, apparently everything was parsed correctly. Now import. */ -- 2.7.4