mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Fix filename generation in export (#2883)
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
@@ -49,12 +49,12 @@ func (f *BaseDirEntry) IsFile() bool {
|
|||||||
|
|
||||||
func (f *BaseDirEntry) Filename() string {
|
func (f *BaseDirEntry) Filename() string {
|
||||||
// prefix with the path depth so that we can import lower-level files/folders first
|
// 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 the full path for a unique filename
|
||||||
hash := md5.FromString(f.Path)
|
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)
|
return fmt.Sprintf("%02x.%s.%s.json", depth, basename, hash)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package jsonschema
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
@@ -22,12 +22,12 @@ type Folder struct {
|
|||||||
|
|
||||||
func (f *Folder) Filename() string {
|
func (f *Folder) Filename() string {
|
||||||
// prefix with the path depth so that we can import lower-level folders first
|
// 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 the full path for a unique filename
|
||||||
hash := md5.FromString(f.Path)
|
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)
|
return fmt.Sprintf("%2x.%s.%s.json", depth, basename, hash)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user