mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +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:
88
pkg/models/repository_file.go
Normal file
88
pkg/models/repository_file.go
Normal file
@@ -0,0 +1,88 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// FileGetter provides methods to get files by ID.
|
||||
type FileGetter interface {
|
||||
Find(ctx context.Context, id ...FileID) ([]File, error)
|
||||
}
|
||||
|
||||
// FileFinder provides methods to find files.
|
||||
type FileFinder interface {
|
||||
FileGetter
|
||||
FindAllByPath(ctx context.Context, path string) ([]File, error)
|
||||
FindAllInPaths(ctx context.Context, p []string, limit, offset int) ([]File, error)
|
||||
FindByPath(ctx context.Context, path string) (File, error)
|
||||
FindByFingerprint(ctx context.Context, fp Fingerprint) ([]File, error)
|
||||
FindByZipFileID(ctx context.Context, zipFileID FileID) ([]File, error)
|
||||
FindByFileInfo(ctx context.Context, info fs.FileInfo, size int64) ([]File, error)
|
||||
}
|
||||
|
||||
// FileQueryer provides methods to query files.
|
||||
type FileQueryer interface {
|
||||
Query(ctx context.Context, options FileQueryOptions) (*FileQueryResult, error)
|
||||
}
|
||||
|
||||
// FileCounter provides methods to count files.
|
||||
type FileCounter interface {
|
||||
CountAllInPaths(ctx context.Context, p []string) (int, error)
|
||||
CountByFolderID(ctx context.Context, folderID FolderID) (int, error)
|
||||
}
|
||||
|
||||
// FileCreator provides methods to create files.
|
||||
type FileCreator interface {
|
||||
Create(ctx context.Context, f File) error
|
||||
}
|
||||
|
||||
// FileUpdater provides methods to update files.
|
||||
type FileUpdater interface {
|
||||
Update(ctx context.Context, f File) error
|
||||
}
|
||||
|
||||
// FileDestroyer provides methods to destroy files.
|
||||
type FileDestroyer interface {
|
||||
Destroy(ctx context.Context, id FileID) error
|
||||
}
|
||||
|
||||
type FileFinderCreator interface {
|
||||
FileFinder
|
||||
FileCreator
|
||||
}
|
||||
|
||||
type FileFinderUpdater interface {
|
||||
FileFinder
|
||||
FileUpdater
|
||||
}
|
||||
|
||||
type FileFinderDestroyer interface {
|
||||
FileFinder
|
||||
FileDestroyer
|
||||
}
|
||||
|
||||
// FileReader provides all methods to read files.
|
||||
type FileReader interface {
|
||||
FileFinder
|
||||
FileQueryer
|
||||
FileCounter
|
||||
|
||||
GetCaptions(ctx context.Context, fileID FileID) ([]*VideoCaption, error)
|
||||
IsPrimary(ctx context.Context, fileID FileID) (bool, error)
|
||||
}
|
||||
|
||||
// FileWriter provides all methods to modify files.
|
||||
type FileWriter interface {
|
||||
FileCreator
|
||||
FileUpdater
|
||||
FileDestroyer
|
||||
|
||||
UpdateCaptions(ctx context.Context, fileID FileID, captions []*VideoCaption) error
|
||||
}
|
||||
|
||||
// FileReaderWriter provides all file methods.
|
||||
type FileReaderWriter interface {
|
||||
FileReader
|
||||
FileWriter
|
||||
}
|
||||
Reference in New Issue
Block a user