From: David ‘Bombe’ Roden Date: Mon, 15 Sep 2014 16:25:07 +0000 (+0200) Subject: Store parsed images locally only, get avatar from local images. X-Git-Tag: 0.9-rc1^2~3^2~125 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4b8ef3b63222f792f32d7fdb623b7baf66f076ba;p=Sone.git Store parsed images locally only, get avatar from local images. --- 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. */