@@ -69,21 +69,22 @@ public class ContributionsIndexer {
69
69
private final File builtInHardwareFolder ;
70
70
private final Platform platform ;
71
71
private final SignatureVerifier signatureVerifier ;
72
- private ContributionsIndex index ;
72
+ private final ContributionsIndex index ;
73
73
74
74
public ContributionsIndexer (File preferencesFolder , File builtInHardwareFolder , Platform platform , SignatureVerifier signatureVerifier ) {
75
75
this .preferencesFolder = preferencesFolder ;
76
76
this .builtInHardwareFolder = builtInHardwareFolder ;
77
77
this .platform = platform ;
78
78
this .signatureVerifier = signatureVerifier ;
79
+ index = new EmptyContributionIndex ();
79
80
packagesFolder = new File (preferencesFolder , "packages" );
80
81
stagingFolder = new File (preferencesFolder , "staging" + File .separator + "packages" );
81
82
}
82
83
83
84
public void parseIndex () throws Exception {
84
85
// Read bundled index...
85
86
File bundledIndexFile = new File (builtInHardwareFolder , Constants .BUNDLED_INDEX_FILE_NAME );
86
- index = parseIndex (bundledIndexFile );
87
+ mergeContributions (bundledIndexFile );
87
88
88
89
// ...and overlay the default index if present
89
90
File defaultIndexFile = getIndexFile (Constants .DEFAULT_INDEX_FILE_NAME );
@@ -93,7 +94,7 @@ public void parseIndex() throws Exception {
93
94
throw new SignatureVerificationFailedException (Constants .DEFAULT_INDEX_FILE_NAME );
94
95
}
95
96
96
- mergeContributions (parseIndex ( defaultIndexFile ), defaultIndexFile );
97
+ mergeContributions (defaultIndexFile );
97
98
}
98
99
99
100
// Set main and bundled indexes as trusted
@@ -104,8 +105,7 @@ public void parseIndex() throws Exception {
104
105
105
106
for (File indexFile : indexFiles ) {
106
107
try {
107
- ContributionsIndex contributionsIndex = parseIndex (indexFile );
108
- mergeContributions (contributionsIndex , indexFile );
108
+ mergeContributions (indexFile );
109
109
} catch (JsonProcessingException e ) {
110
110
System .err .println (I18n .format (tr ("Skipping contributed index file {0}, parsing error occured:" ), indexFile ));
111
111
System .err .println (e );
@@ -136,7 +136,11 @@ public void parseIndex() throws Exception {
136
136
index .fillCategories ();
137
137
}
138
138
139
- private void mergeContributions (ContributionsIndex contributionsIndex , File indexFile ) {
139
+ private void mergeContributions (File indexFile ) throws IOException {
140
+ if (!indexFile .exists ())
141
+ return ;
142
+
143
+ ContributionsIndex contributionsIndex = parseIndex (indexFile );
140
144
boolean signed = signatureVerifier .isSigned (indexFile );
141
145
boolean trustall = PreferencesData .getBoolean (Constants .PREF_CONTRIBUTIONS_TRUST_ALL );
142
146
0 commit comments