From 276f14cdcba1d6d6b00f60b52dc627b7778c8c71 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 5 Sep 2022 12:14:41 +1000 Subject: [PATCH] Fix filename generation in export (#2883) --- pkg/models/jsonschema/file_folder.go | 6 +++--- pkg/models/jsonschema/folder.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/models/jsonschema/file_folder.go b/pkg/models/jsonschema/file_folder.go index a389b20e5..1e4675d84 100644 --- a/pkg/models/jsonschema/file_folder.go +++ b/pkg/models/jsonschema/file_folder.go @@ -6,7 +6,7 @@ import ( "fmt" "io/ioutil" "os" - "path" + "path/filepath" "strings" jsoniter "github.com/json-iterator/go" @@ -49,12 +49,12 @@ func (f *BaseDirEntry) IsFile() bool { func (f *BaseDirEntry) Filename() string { // prefix with the path depth so that we can import lower-level files/folders first - depth := strings.Count(f.Path, string("/")) + depth := strings.Count(f.Path, string(filepath.Separator)) // hash the full path for a unique filename hash := md5.FromString(f.Path) - basename := path.Base(f.Path) + basename := filepath.Base(f.Path) return fmt.Sprintf("%02x.%s.%s.json", depth, basename, hash) } diff --git a/pkg/models/jsonschema/folder.go b/pkg/models/jsonschema/folder.go index 090663668..080a2275c 100644 --- a/pkg/models/jsonschema/folder.go +++ b/pkg/models/jsonschema/folder.go @@ -3,7 +3,7 @@ package jsonschema import ( "fmt" "os" - "path" + "path/filepath" "strings" jsoniter "github.com/json-iterator/go" @@ -22,12 +22,12 @@ type Folder struct { func (f *Folder) Filename() string { // prefix with the path depth so that we can import lower-level folders first - depth := strings.Count(f.Path, string("/")) + depth := strings.Count(f.Path, string(filepath.Separator)) // hash the full path for a unique filename hash := md5.FromString(f.Path) - basename := path.Base(f.Path) + basename := filepath.Base(f.Path) return fmt.Sprintf("%2x.%s.%s.json", depth, basename, hash) }