@@ -168,6 +168,19 @@ static String getPropertiesFileName(Type type) {
168
168
return null ;
169
169
}
170
170
171
+ static File getSketchbookContribFolder (Base base , Type type ) {
172
+ switch (type ) {
173
+ case LIBRARY :
174
+ case LIBRARY_COMPILATION :
175
+ return base .getSketchbookLibrariesFolder ();
176
+ case TOOL :
177
+ return base .getSketchbookToolsFolder ();
178
+ case MODE :
179
+ return base .getSketchbookModesFolder ();
180
+ }
181
+ return null ;
182
+ }
183
+
171
184
static InstalledContribution create (Base base , Type type , File folder ) {
172
185
switch (type ) {
173
186
case LIBRARY :
@@ -286,17 +299,16 @@ static public InstalledContribution installContribution(Editor editor, Installed
286
299
287
300
String libFolderName = newLib .getFolder ().getName ();
288
301
289
- File libraryDestination = editor .getBase ().getSketchbookLibrariesFolder ();
302
+ File libraryDestination = ContributionManager
303
+ .getSketchbookContribFolder (editor .getBase (), newLib .getType ());
290
304
File newLibDest = new File (libraryDestination , libFolderName );
291
305
292
306
for (InstalledContribution oldLib : oldLibs ) {
293
307
294
- // XXX: Handle other cases when installing libraries.
295
- // -What if a library by the same name is already installed?
296
- // -What if newLibDest exists, but isn't used by an existing library?
297
- if (oldLib .getFolder ().exists () && oldLib .getFolder ().equals (newLibDest )) {
308
+ if ((oldLib .getFolder ().exists () && oldLib .getFolder ().equals (newLibDest ))
309
+ || (oldLib .getId () != null && oldLib .getId ().equals (newLib .getId ()))) {
298
310
299
- if (ContributionManager .requiresRestart (newLib )) {
311
+ if (ContributionManager .requiresRestart (oldLib )) {
300
312
// XXX: We can't replace stuff, soooooo.... do something different
301
313
if (!backupContribution (editor , oldLib , false , statusBar )) {
302
314
return null ;
0 commit comments