Skip to content

Commit 5875909

Browse files
author
Federico Fissore
committed
Folder/zip file is checked to be an actual library before importing it. Fixes arduino#2861
1 parent 25b886d commit 5875909

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

app/src/processing/app/Base.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,17 @@ public void handleAddLibrary() {
24832483
return;
24842484
}
24852485

2486+
String[] headers;
2487+
if (new File(libFolder, "library.properties").exists()) {
2488+
headers = BaseNoGui.headerListFromIncludePath(UserLibrary.create(libFolder).getSrcFolder());
2489+
} else {
2490+
headers = BaseNoGui.headerListFromIncludePath(libFolder);
2491+
}
2492+
if (headers.length == 0) {
2493+
activeEditor.statusError(_("Specified folder/zip file does not contain a valid library"));
2494+
return;
2495+
}
2496+
24862497
// copy folder
24872498
File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder(), sourceFile.getName());
24882499
if (!destinationFolder.mkdir()) {
@@ -2496,6 +2507,8 @@ public void handleAddLibrary() {
24962507
return;
24972508
}
24982509
activeEditor.statusNotice(_("Library added to your libraries. Check \"Include library\" menu"));
2510+
} catch (IOException e) {
2511+
// FIXME error when importing. ignoring :(
24992512
} finally {
25002513
// delete zip created temp folder, if exists
25012514
FileUtils.recursiveDelete(tmpFolder);

0 commit comments

Comments
 (0)