mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +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;
|
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
|
// copy folder
|
||||||
File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder(), sourceFile.getName());
|
File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder(), sourceFile.getName());
|
||||||
if (!destinationFolder.mkdir()) {
|
if (!destinationFolder.mkdir()) {
|
||||||
@ -2496,6 +2507,8 @@ public class Base {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activeEditor.statusNotice(_("Library added to your libraries. Check \"Include library\" menu"));
|
activeEditor.statusNotice(_("Library added to your libraries. Check \"Include library\" menu"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
// FIXME error when importing. ignoring :(
|
||||||
} finally {
|
} finally {
|
||||||
// delete zip created temp folder, if exists
|
// delete zip created temp folder, if exists
|
||||||
FileUtils.recursiveDelete(tmpFolder);
|
FileUtils.recursiveDelete(tmpFolder);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user