Folder/zip file is checked to be an actual library before importing it. Fixes #2861

This commit is contained in:
Federico Fissore 2015-06-04 16:28:07 +02:00
parent 25b886dee3
commit 5875909683
1 changed files with 13 additions and 0 deletions

View File

@ -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);