mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 10:41:06 +01:00
Fix duplicate plugins in the plugin tree after update
This commit is contained in:
@@ -31,6 +31,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -105,6 +106,25 @@ public final class ExplodedSmp
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ExplodedSmp that = (ExplodedSmp) o;
|
||||
return path.equals(that.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
PluginInformation information = plugin.getInformation();
|
||||
return information.getName() + "@" + information.getVersion() + " (" + path + ")";
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -190,8 +190,14 @@ public final class PluginProcessor
|
||||
return ImmutableSet.copyOf(wrappers);
|
||||
}
|
||||
|
||||
private ImmutableSet<ExplodedSmp> concat(Set<ExplodedSmp> installedPlugins, Set<ExplodedSmp> newlyInstalledPlugins) {
|
||||
return ImmutableSet.<ExplodedSmp>builder().addAll(installedPlugins).addAll(newlyInstalledPlugins).build();
|
||||
private Set<ExplodedSmp> concat(Set<ExplodedSmp> installedPlugins, Set<ExplodedSmp> newlyInstalledPlugins) {
|
||||
// We first add all newly installed plugins,
|
||||
// after that we add the missing plugins, which are already installed.
|
||||
// ExplodedSmp is equal by its path, so duplicates (updates) are not in the result.
|
||||
return ImmutableSet.<ExplodedSmp>builder()
|
||||
.addAll(newlyInstalledPlugins)
|
||||
.addAll(installedPlugins)
|
||||
.build();
|
||||
}
|
||||
|
||||
private Set<ExplodedSmp> installPending(Set<ExplodedSmp> installedPlugins) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user