Skip to content

Commit a214564

Browse files
author
Federico Fissore
committed
Boards Manager: platforms listed in non-signed package index files goes under "Contributed" category
1 parent cddfa28 commit a214564

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

arduino-core/src/cc/arduino/contributions/packages/ContributedPlatform.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public abstract class ContributedPlatform extends DownloadableContribution {
3939

4040
public abstract String getCategory();
4141

42+
public abstract void setCategory(String category);
43+
4244
public abstract String getArchitecture();
4345

4446
public abstract String getChecksum();

arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,21 @@ public void parseIndex() throws Exception {
9797
}
9898

9999
private void mergeContributions(ContributionsIndex contributionsIndex, File indexFile) {
100+
boolean signed = isSigned(indexFile);
101+
100102
for (ContributedPackage contributedPackage : contributionsIndex.getPackages()) {
103+
if (!signed) {
104+
for (ContributedPlatform contributedPlatform : contributedPackage.getPlatforms()) {
105+
contributedPlatform.setCategory("Contributed");
106+
}
107+
}
108+
101109
ContributedPackage targetPackage = index.getPackage(contributedPackage.getName());
102110

103111
if (targetPackage == null) {
104112
index.getPackages().add(contributedPackage);
105113
} else {
106-
if (mergeAllowed(contributedPackage, indexFile)) {
114+
if (signed || !isPackageNameProtected(contributedPackage)) {
107115
List<ContributedPlatform> platforms = contributedPackage.getPlatforms();
108116
if (platforms == null) {
109117
platforms = new LinkedList<ContributedPlatform>();
@@ -131,8 +139,8 @@ private void mergeContributions(ContributionsIndex contributionsIndex, File inde
131139
}
132140
}
133141

134-
private boolean mergeAllowed(ContributedPackage contributedPackage, File indexFile) {
135-
return !Constants.PROTECTED_PACKAGE_NAMES.contains(contributedPackage.getName()) || isSigned(indexFile);
142+
private boolean isPackageNameProtected(ContributedPackage contributedPackage) {
143+
return Constants.PROTECTED_PACKAGE_NAMES.contains(contributedPackage.getName());
136144
}
137145

138146
private boolean isSigned(File indexFile) {

0 commit comments

Comments
 (0)