Skip to content

Commit 067d51d

Browse files
committed
use ids when installing contributions
1 parent 6857d77 commit 067d51d

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

app/src/processing/app/ContributionManager.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ static String getPropertiesFileName(Type type) {
168168
return null;
169169
}
170170

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+
171184
static InstalledContribution create(Base base, Type type, File folder) {
172185
switch (type) {
173186
case LIBRARY:
@@ -286,17 +299,16 @@ static public InstalledContribution installContribution(Editor editor, Installed
286299

287300
String libFolderName = newLib.getFolder().getName();
288301

289-
File libraryDestination = editor.getBase().getSketchbookLibrariesFolder();
302+
File libraryDestination = ContributionManager
303+
.getSketchbookContribFolder(editor.getBase(), newLib.getType());
290304
File newLibDest = new File(libraryDestination, libFolderName);
291305

292306
for (InstalledContribution oldLib : oldLibs) {
293307

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()))) {
298310

299-
if (ContributionManager.requiresRestart(newLib)) {
311+
if (ContributionManager.requiresRestart(oldLib)) {
300312
// XXX: We can't replace stuff, soooooo.... do something different
301313
if (!backupContribution(editor, oldLib, false, statusBar)) {
302314
return null;

app/src/processing/app/contribution/InstalledContribution.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
public abstract class InstalledContribution implements Contribution {
3131

3232
protected String name; // "pdf" or "PDF Export"
33+
protected String id; // 1
3334
protected String category; // "Sound"
3435
protected String authorList; // Ben Fry
3536
protected String url; // http://processing.org
@@ -52,6 +53,7 @@ public InstalledContribution(File folder, String propertiesFileName) {
5253
properties = Base.readSettings(propertiesFile);
5354

5455
name = properties.get("name");
56+
id = properties.get("id");
5557
category = ContributionListing.getCategory(properties.get("category"));
5658
if (name == null) {
5759
name = folder.getName();
@@ -86,6 +88,10 @@ public String getName() {
8688
return name;
8789
}
8890

91+
public String getId() {
92+
return id;
93+
}
94+
8995
public String getAuthorList() {
9096
return authorList;
9197
}

0 commit comments

Comments
 (0)