@@ -69,21 +69,22 @@ public class ContributionsIndexer {
6969 private final File builtInHardwareFolder ;
7070 private final Platform platform ;
7171 private final SignatureVerifier signatureVerifier ;
72- private ContributionsIndex index ;
72+ private final ContributionsIndex index ;
7373
7474 public ContributionsIndexer (File preferencesFolder , File builtInHardwareFolder , Platform platform , SignatureVerifier signatureVerifier ) {
7575 this .preferencesFolder = preferencesFolder ;
7676 this .builtInHardwareFolder = builtInHardwareFolder ;
7777 this .platform = platform ;
7878 this .signatureVerifier = signatureVerifier ;
79+ index = new EmptyContributionIndex ();
7980 packagesFolder = new File (preferencesFolder , "packages" );
8081 stagingFolder = new File (preferencesFolder , "staging" + File .separator + "packages" );
8182 }
8283
8384 public void parseIndex () throws Exception {
8485 // Read bundled index...
8586 File bundledIndexFile = new File (builtInHardwareFolder , Constants .BUNDLED_INDEX_FILE_NAME );
86- index = parseIndex (bundledIndexFile );
87+ mergeContributions (bundledIndexFile );
8788
8889 // ...and overlay the default index if present
8990 File defaultIndexFile = getIndexFile (Constants .DEFAULT_INDEX_FILE_NAME );
@@ -93,7 +94,7 @@ public void parseIndex() throws Exception {
9394 throw new SignatureVerificationFailedException (Constants .DEFAULT_INDEX_FILE_NAME );
9495 }
9596
96- mergeContributions (parseIndex ( defaultIndexFile ), defaultIndexFile );
97+ mergeContributions (defaultIndexFile );
9798 }
9899
99100 // Set main and bundled indexes as trusted
@@ -104,8 +105,7 @@ public void parseIndex() throws Exception {
104105
105106 for (File indexFile : indexFiles ) {
106107 try {
107- ContributionsIndex contributionsIndex = parseIndex (indexFile );
108- mergeContributions (contributionsIndex , indexFile );
108+ mergeContributions (indexFile );
109109 } catch (JsonProcessingException e ) {
110110 System .err .println (I18n .format (tr ("Skipping contributed index file {0}, parsing error occured:" ), indexFile ));
111111 System .err .println (e );
@@ -136,7 +136,11 @@ public void parseIndex() throws Exception {
136136 index .fillCategories ();
137137 }
138138
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 );
140144 boolean signed = signatureVerifier .isSigned (indexFile );
141145 boolean trustall = PreferencesData .getBoolean (Constants .PREF_CONTRIBUTIONS_TRUST_ALL );
142146
0 commit comments