X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=7a8f5df4acd867d708ba3d1b6bafbd3fcd2698c2;hp=02289515651f5480db0d8ac566ed571bb8e8cdda;hb=509b81185b3a1e82bb78308640d0d7b6b741d3e0;hpb=6d422fb5879ac6f6211973cf99de9b55f16f1f72 diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 0228951..7a8f5df 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1,5 +1,5 @@ /* - * Sone - Core.java - Copyright © 2010–2019 David Roden + * Sone - Core.java - Copyright © 2010–2020 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,6 +53,7 @@ import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidPostFound; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidPostReplyFound; import net.pterodactylus.sone.core.event.*; import net.pterodactylus.sone.data.Album; +import net.pterodactylus.sone.data.AlbumsKt; import net.pterodactylus.sone.data.Client; import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Post; @@ -90,7 +91,6 @@ import net.pterodactylus.util.thread.NamedThreadFactory; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Stopwatch; -import com.google.common.collect.FluentIterable; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; @@ -180,24 +180,10 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, private final MetricRegistry metricRegistry; private final Histogram configurationSaveTimeHistogram; - /** - * Creates a new core. - * - * @param configuration - * The configuration of the core - * @param freenetInterface - * The freenet interface - * @param identityManager - * The identity manager - * @param webOfTrustUpdater - * The WebOfTrust updater - * @param eventBus - * The event bus - * @param database - * The database - */ + private final SoneUriCreator soneUriCreator; + @Inject - public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, SoneDownloader soneDownloader, ImageInserter imageInserter, UpdateChecker updateChecker, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database, MetricRegistry metricRegistry) { + public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, SoneDownloader soneDownloader, ImageInserter imageInserter, UpdateChecker updateChecker, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database, MetricRegistry metricRegistry, SoneUriCreator soneUriCreator) { super("Sone Core"); this.configuration = configuration; this.freenetInterface = freenetInterface; @@ -209,6 +195,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, this.eventBus = eventBus; this.database = database; this.metricRegistry = metricRegistry; + this.soneUriCreator = soneUriCreator; preferences = new Preferences(eventBus); this.configurationSaveTimeHistogram = metricRegistry.histogram("configuration.save.duration", () -> new Histogram(new ExponentiallyDecayingReservoir(3000, 0))); } @@ -626,7 +613,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, sone.setLatestEdition(fromNullable(tryParse(property)).or(0L)); sone.setClient(new Client("Sone", SonePlugin.getPluginVersion())); sone.setKnown(true); - SoneInserter soneInserter = new SoneInserter(this, eventBus, freenetInterface, metricRegistry, ownIdentity.getId()); + SoneInserter soneInserter = new SoneInserter(this, eventBus, freenetInterface, metricRegistry, soneUriCreator, ownIdentity.getId()); soneInserter.insertionDelayChanged(new InsertionDelayChangedEvent(preferences.getInsertionDelay())); eventBus.register(soneInserter); synchronized (soneInserters) { @@ -1405,7 +1392,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, configuration.getStringValue(sonePrefix + "/Likes/Reply/" + replyLikeCounter + "/ID").setValue(null); /* save albums. first, collect in a flat structure, top-level first. */ - List albums = FluentIterable.from(sone.getRootAlbum().getAlbums()).transformAndConcat(Album.FLATTENER).toList(); + List albums = AlbumsKt.getAllAlbums(sone.getRootAlbum()); int albumCounter = 0; for (Album album : albums) {