mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Maintain saved filters in full export/import (#5465)
* Remove ellipsis from full export button
This commit is contained in:
31
pkg/models/jsonschema/load.go
Normal file
31
pkg/models/jsonschema/load.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package jsonschema
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
func loadFile[T any](filePath string) (*T, error) {
|
||||
var ret T
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
jsonParser := json.NewDecoder(file)
|
||||
err = jsonParser.Decode(&ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func saveFile[T any](filePath string, obj *T) error {
|
||||
if obj == nil {
|
||||
return fmt.Errorf("object must not be nil")
|
||||
}
|
||||
return marshalToFile(filePath, obj)
|
||||
}
|
||||
Reference in New Issue
Block a user