Skip to content

Commit

Permalink
specify which file tounzip
Browse files Browse the repository at this point in the history
  • Loading branch information
stackdump committed Dec 31, 2023
1 parent 542c3f9 commit 21be2cc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions metamodel/metamodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ type MetaModel interface {
Execute(...Vector) Process
Edit() Editor
Node(oid string) Node
UnzipUrl(url string) (json string, ok bool)
UnzipUrl(url string, filename string) (obj string, ok bool)
ZipUrl(...string) (url string, ok bool)
GetViewPort() (int, int, int, int)
}
Expand Down Expand Up @@ -583,7 +583,7 @@ func (m *Model) ZipUrl(path ...string) (url string, ok bool) {
return "", false
}

func (m *Model) UnzipUrl(url string) (obj string, ok bool) {
func (m *Model) UnzipUrl(url string, filename string) (obj string, ok bool) {
queryString := ""
ok = false
if i := strings.Index(url, "?"); i > -1 {
Expand All @@ -609,8 +609,10 @@ func (m *Model) UnzipUrl(url string) (obj string, ok bool) {
panic(zipErr)
}
for _, file := range zipReader.File {
if file.Name != "model.json" {
if file.Name != filename {
continue
} else {
ok = true
}
fileReader, err := file.Open()
if err != nil {
Expand All @@ -621,7 +623,10 @@ func (m *Model) UnzipUrl(url string) (obj string, ok bool) {
obj = buf.String()
}
}
ok = m.loadJsonDefinition(obj)

if filename == "model.json" {
ok = m.loadJsonDefinition(obj)
}
return obj, ok
}

Expand Down

0 comments on commit 21be2cc

Please sign in to comment.