fix bug finding example resource
This commit is contained in:
parent
e5af619105
commit
cc66ce9f34
|
@ -39,6 +39,7 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
|
@ -297,6 +298,14 @@ public class NPMPackageGenerator {
|
|||
if (!path.startsWith("package/")) {
|
||||
path = "package/" +path;
|
||||
}
|
||||
if (path.length() > 100) {
|
||||
name = name.substring(0, name.indexOf("-"))+"-"+UUID.randomUUID().toString();
|
||||
path = cat.getDirectory()+name;
|
||||
if (!path.startsWith("package/")) {
|
||||
path = "package/" +path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (created.contains(path)) {
|
||||
System.out.println("Duplicate package file "+path);
|
||||
|
|
|
@ -575,6 +575,20 @@ public class NpmPackage {
|
|||
return null;
|
||||
}
|
||||
|
||||
public InputStream loadExampleResource(String type, String id) throws IOException {
|
||||
NpmPackageFolder f = folders.get("example");
|
||||
if (f != null) {
|
||||
JsonArray files = f.index.getAsJsonArray("files");
|
||||
for (JsonElement e : files) {
|
||||
JsonObject i = (JsonObject) e;
|
||||
if (type.equals(JSONUtil.str(i, "resourceType")) && id.equals(JSONUtil.str(i, "id"))) {
|
||||
return load("example", JSONUtil.str(i, "filename"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** special case when playing around inside the package **/
|
||||
public Map<String, NpmPackageFolder> getFolders() {
|
||||
return folders;
|
||||
|
|
Loading…
Reference in New Issue