mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Folder/zip file is checked to be an actual library before importing it. Fixes #2861
This commit is contained in:
parent
25b886dee3
commit
5875909683
@ -2483,6 +2483,17 @@ public class Base {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] headers;
|
||||
if (new File(libFolder, "library.properties").exists()) {
|
||||
headers = BaseNoGui.headerListFromIncludePath(UserLibrary.create(libFolder).getSrcFolder());
|
||||
} else {
|
||||
headers = BaseNoGui.headerListFromIncludePath(libFolder);
|
||||
}
|
||||
if (headers.length == 0) {
|
||||
activeEditor.statusError(_("Specified folder/zip file does not contain a valid library"));
|
||||
return;
|
||||
}
|
||||
|
||||
// copy folder
|
||||
File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder(), sourceFile.getName());
|
||||
if (!destinationFolder.mkdir()) {
|
||||
@ -2496,6 +2507,8 @@ public class Base {
|
||||
return;
|
||||
}
|
||||
activeEditor.statusNotice(_("Library added to your libraries. Check \"Include library\" menu"));
|
||||
} catch (IOException e) {
|
||||
// FIXME error when importing. ignoring :(
|
||||
} finally {
|
||||
// delete zip created temp folder, if exists
|
||||
FileUtils.recursiveDelete(tmpFolder);
|
||||
|
Loading…
x
Reference in New Issue
Block a user