From 587590968356aeafb7b587ff16f6efad26e95bec Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Thu, 4 Jun 2015 16:28:07 +0200 Subject: [PATCH] Folder/zip file is checked to be an actual library before importing it. Fixes #2861 --- app/src/processing/app/Base.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index d3ca957d6..8958bb4e5 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -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);