Fix filename generation in export (#2883)

This commit is contained in:
WithoutPants
2022-09-05 12:14:41 +10:00
parent 6b0bcdea88
commit 276f14cdcb
2 changed files with 6 additions and 6 deletions

View File

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

View File

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