mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Fix filename generation in export (#2883)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user