stash/pkg/models/repository_file.go
DingDongSoLong4 c364346a59
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
2023-09-01 10:39:29 +10:00

88 lines
2.2 KiB
Go

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
}