Selective export (#770)

This commit is contained in:
WithoutPants
2020-09-15 17:28:53 +10:00
committed by GitHub
parent 03f5e1a442
commit 03d4826c85
280 changed files with 40619 additions and 13035 deletions

View File

@@ -2,62 +2,65 @@ package manager
import (
"github.com/stashapp/stash/pkg/manager/jsonschema"
"github.com/stashapp/stash/pkg/manager/paths"
)
type jsonUtils struct{}
type jsonUtils struct {
json paths.JSONPaths
}
func (jp *jsonUtils) getMappings() (*jsonschema.Mappings, error) {
return jsonschema.LoadMappingsFile(instance.Paths.JSON.MappingsFile)
return jsonschema.LoadMappingsFile(jp.json.MappingsFile)
}
func (jp *jsonUtils) saveMappings(mappings *jsonschema.Mappings) error {
return jsonschema.SaveMappingsFile(instance.Paths.JSON.MappingsFile, mappings)
return jsonschema.SaveMappingsFile(jp.json.MappingsFile, mappings)
}
func (jp *jsonUtils) getScraped() ([]jsonschema.ScrapedItem, error) {
return jsonschema.LoadScrapedFile(instance.Paths.JSON.ScrapedFile)
return jsonschema.LoadScrapedFile(jp.json.ScrapedFile)
}
func (jp *jsonUtils) saveScaped(scraped []jsonschema.ScrapedItem) error {
return jsonschema.SaveScrapedFile(instance.Paths.JSON.ScrapedFile, scraped)
return jsonschema.SaveScrapedFile(jp.json.ScrapedFile, scraped)
}
func (jp *jsonUtils) getPerformer(checksum string) (*jsonschema.Performer, error) {
return jsonschema.LoadPerformerFile(instance.Paths.JSON.PerformerJSONPath(checksum))
return jsonschema.LoadPerformerFile(jp.json.PerformerJSONPath(checksum))
}
func (jp *jsonUtils) savePerformer(checksum string, performer *jsonschema.Performer) error {
return jsonschema.SavePerformerFile(instance.Paths.JSON.PerformerJSONPath(checksum), performer)
return jsonschema.SavePerformerFile(jp.json.PerformerJSONPath(checksum), performer)
}
func (jp *jsonUtils) getStudio(checksum string) (*jsonschema.Studio, error) {
return jsonschema.LoadStudioFile(instance.Paths.JSON.StudioJSONPath(checksum))
return jsonschema.LoadStudioFile(jp.json.StudioJSONPath(checksum))
}
func (jp *jsonUtils) saveStudio(checksum string, studio *jsonschema.Studio) error {
return jsonschema.SaveStudioFile(instance.Paths.JSON.StudioJSONPath(checksum), studio)
return jsonschema.SaveStudioFile(jp.json.StudioJSONPath(checksum), studio)
}
func (jp *jsonUtils) getTag(checksum string) (*jsonschema.Tag, error) {
return jsonschema.LoadTagFile(instance.Paths.JSON.TagJSONPath(checksum))
return jsonschema.LoadTagFile(jp.json.TagJSONPath(checksum))
}
func (jp *jsonUtils) saveTag(checksum string, tag *jsonschema.Tag) error {
return jsonschema.SaveTagFile(instance.Paths.JSON.TagJSONPath(checksum), tag)
return jsonschema.SaveTagFile(jp.json.TagJSONPath(checksum), tag)
}
func (jp *jsonUtils) getMovie(checksum string) (*jsonschema.Movie, error) {
return jsonschema.LoadMovieFile(instance.Paths.JSON.MovieJSONPath(checksum))
return jsonschema.LoadMovieFile(jp.json.MovieJSONPath(checksum))
}
func (jp *jsonUtils) saveMovie(checksum string, movie *jsonschema.Movie) error {
return jsonschema.SaveMovieFile(instance.Paths.JSON.MovieJSONPath(checksum), movie)
return jsonschema.SaveMovieFile(jp.json.MovieJSONPath(checksum), movie)
}
func (jp *jsonUtils) getScene(checksum string) (*jsonschema.Scene, error) {
return jsonschema.LoadSceneFile(instance.Paths.JSON.SceneJSONPath(checksum))
return jsonschema.LoadSceneFile(jp.json.SceneJSONPath(checksum))
}
func (jp *jsonUtils) saveScene(checksum string, scene *jsonschema.Scene) error {
return jsonschema.SaveSceneFile(instance.Paths.JSON.SceneJSONPath(checksum), scene)
return jsonschema.SaveSceneFile(jp.json.SceneJSONPath(checksum), scene)
}