mirror of
https://github.com/stashapp/stash.git
synced 2025-12-13 11:52:46 +01:00
* Add grid view for tags * Add tag page * Import/export tags * Add tag name uniqueness checks * Fix styling on missing marker previews * Add trace loglevel * Add SQL trace * Add filter options for tags * Add tag sort by options * Add tag page keyboard shortcuts
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package jsonschema
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
jsoniter "github.com/json-iterator/go"
|
|
)
|
|
|
|
type NameMapping struct {
|
|
Name string `json:"name"`
|
|
Checksum string `json:"checksum"`
|
|
}
|
|
|
|
type PathMapping struct {
|
|
Path string `json:"path"`
|
|
Checksum string `json:"checksum"`
|
|
}
|
|
|
|
type Mappings struct {
|
|
Tags []NameMapping `json:"tags"`
|
|
Performers []NameMapping `json:"performers"`
|
|
Studios []NameMapping `json:"studios"`
|
|
Movies []NameMapping `json:"movies"`
|
|
Galleries []PathMapping `json:"galleries"`
|
|
Scenes []PathMapping `json:"scenes"`
|
|
}
|
|
|
|
func LoadMappingsFile(filePath string) (*Mappings, error) {
|
|
var mappings Mappings
|
|
file, err := os.Open(filePath)
|
|
defer file.Close()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
|
jsonParser := json.NewDecoder(file)
|
|
err = jsonParser.Decode(&mappings)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &mappings, nil
|
|
}
|
|
|
|
func SaveMappingsFile(filePath string, mappings *Mappings) error {
|
|
if mappings == nil {
|
|
return fmt.Errorf("mappings must not be nil")
|
|
}
|
|
return marshalToFile(filePath, mappings)
|
|
}
|