mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Model refactor (#3915)
* Add mockery config file * Move basic file/folder structs to models * Fix hack due to import loop * Move file interfaces to models * Move folder interfaces to models * Move scene interfaces to models * Move scene marker interfaces to models * Move image interfaces to models * Move gallery interfaces to models * Move gallery chapter interfaces to models * Move studio interfaces to models * Move movie interfaces to models * Move performer interfaces to models * Move tag interfaces to models * Move autotag interfaces to models * Regenerate mocks
This commit is contained in:
@@ -5,22 +5,25 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/performer"
|
||||
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
|
||||
"github.com/stashapp/stash/pkg/studio"
|
||||
"github.com/stashapp/stash/pkg/tag"
|
||||
)
|
||||
|
||||
type ImporterReaderWriter interface {
|
||||
models.GalleryCreatorUpdater
|
||||
FindByFileID(ctx context.Context, fileID models.FileID) ([]*models.Gallery, error)
|
||||
FindByFolderID(ctx context.Context, folderID models.FolderID) ([]*models.Gallery, error)
|
||||
FindUserGalleryByTitle(ctx context.Context, title string) ([]*models.Gallery, error)
|
||||
}
|
||||
|
||||
type Importer struct {
|
||||
ReaderWriter FullCreatorUpdater
|
||||
StudioWriter studio.NameFinderCreator
|
||||
PerformerWriter performer.NameFinderCreator
|
||||
TagWriter tag.NameFinderCreator
|
||||
FileFinder file.Getter
|
||||
FolderFinder file.FolderGetter
|
||||
ReaderWriter ImporterReaderWriter
|
||||
StudioWriter models.StudioFinderCreator
|
||||
PerformerWriter models.PerformerFinderCreator
|
||||
TagWriter models.TagFinderCreator
|
||||
FileFinder models.FileFinder
|
||||
FolderFinder models.FolderFinder
|
||||
Input jsonschema.Gallery
|
||||
MissingRefBehaviour models.ImportMissingRefEnum
|
||||
|
||||
@@ -28,11 +31,6 @@ type Importer struct {
|
||||
gallery models.Gallery
|
||||
}
|
||||
|
||||
type FullCreatorUpdater interface {
|
||||
FinderCreatorUpdater
|
||||
Update(ctx context.Context, updatedGallery *models.Gallery) error
|
||||
}
|
||||
|
||||
func (i *Importer) PreImport(ctx context.Context) error {
|
||||
i.gallery = i.galleryJSONToGallery(i.Input)
|
||||
|
||||
@@ -251,7 +249,7 @@ func (i *Importer) createTags(ctx context.Context, names []string) ([]*models.Ta
|
||||
}
|
||||
|
||||
func (i *Importer) populateFilesFolder(ctx context.Context) error {
|
||||
files := make([]file.File, 0)
|
||||
files := make([]models.File, 0)
|
||||
|
||||
for _, ref := range i.Input.ZipFiles {
|
||||
path := ref
|
||||
@@ -340,7 +338,7 @@ func (i *Importer) FindExistingID(ctx context.Context) (*int, error) {
|
||||
}
|
||||
|
||||
func (i *Importer) Create(ctx context.Context) (*int, error) {
|
||||
var fileIDs []file.ID
|
||||
var fileIDs []models.FileID
|
||||
for _, f := range i.gallery.Files.List() {
|
||||
fileIDs = append(fileIDs, f.Base().ID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user