From 5b8a24528791c4daa54176824f7110d6463ab03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 11 May 2024 08:07:24 +0200 Subject: [PATCH] AbstractRepositoryManager does not pass the nickname Currently if a discovery event would define a nickname it is not passed by the add repository method resulting in an updatesite to have an empty name. This adds a new method that allows to pass a custom RepositoryInfo so the nickname can be set. --- .../helpers/AbstractRepositoryManager.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java index dd36efc788..310c14e149 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java @@ -160,18 +160,23 @@ private boolean addRepository(URI location, boolean isEnabled, boolean signalAdd RepositoryInfo info = new RepositoryInfo<>(); info.location = location; info.isEnabled = isEnabled; + return addRepository(info, signalAdd); + } + + private boolean addRepository(RepositoryInfo info, boolean signalAdd) { + boolean added = true; synchronized (repositoryLock) { if (repositories == null) restoreRepositories(); - if (contains(location)) + if (contains(info.location)) return false; - added = repositories.put(getKey(location), info) == null; + added = repositories.put(getKey(info.location), info) == null; // save the given repository in the preferences. remember(info, true); } if (added && signalAdd) - broadcastChangeEvent(location, getRepositoryType(), RepositoryEvent.ADDED, isEnabled); + broadcastChangeEvent(info.location, getRepositoryType(), RepositoryEvent.ADDED, info.isEnabled); return added; } @@ -837,8 +842,13 @@ private boolean matchesFlags(RepositoryInfo info, int flags) { public void notify(EventObject o) { if (o instanceof RepositoryEvent) { RepositoryEvent event = (RepositoryEvent) o; - if (event.getKind() == RepositoryEvent.DISCOVERED && event.getRepositoryType() == getRepositoryType()) - addRepository(event.getRepositoryLocation(), event.isRepositoryEnabled(), true); + if (event.getKind() == RepositoryEvent.DISCOVERED && event.getRepositoryType() == getRepositoryType()) { + RepositoryInfo info = new RepositoryInfo<>(); + info.location = event.getRepositoryLocation(); + info.isEnabled = event.isRepositoryEnabled(); + info.nickname = event.getRepositoryNickname(); + addRepository(info, true); + } } }