mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
* Remove manager.Repository * Refactor other repositories * Fix tests and add database mock * Add AssertExpectations method * Refactor routes * Move default movie image to internal/static and add convenience methods * Refactor default performer image boxes
36 lines
848 B
Go
36 lines
848 B
Go
package file
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
"github.com/stashapp/stash/pkg/txn"
|
|
)
|
|
|
|
// Repository provides access to storage methods for files and folders.
|
|
type Repository struct {
|
|
TxnManager models.TxnManager
|
|
|
|
File models.FileReaderWriter
|
|
Folder models.FolderReaderWriter
|
|
}
|
|
|
|
func NewRepository(repo models.Repository) Repository {
|
|
return Repository{
|
|
TxnManager: repo.TxnManager,
|
|
File: repo.File,
|
|
Folder: repo.Folder,
|
|
}
|
|
}
|
|
|
|
func (r *Repository) WithTxn(ctx context.Context, fn txn.TxnFunc) error {
|
|
return txn.WithTxn(ctx, r.TxnManager, fn)
|
|
}
|
|
|
|
func (r *Repository) WithReadTxn(ctx context.Context, fn txn.TxnFunc) error {
|
|
return txn.WithReadTxn(ctx, r.TxnManager, fn)
|
|
}
|
|
|
|
func (r *Repository) WithDB(ctx context.Context, fn txn.TxnFunc) error {
|
|
return txn.WithDatabase(ctx, r.TxnManager, fn)
|
|
}
|