mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Restructure data layer (#2532)
* Add new txn manager interface * Add txn management to sqlite * Rename get to getByID * Add contexts to repository methods * Update query builders * Add context to reader writer interfaces * Use repository in resolver * Tighten interfaces * Tighten interfaces in dlna * Tighten interfaces in match package * Tighten interfaces in scraper package * Tighten interfaces in scan code * Tighten interfaces on autotag package * Remove ReaderWriter usage * Merge database package into sqlite
This commit is contained in:
@@ -24,7 +24,7 @@ import (
|
||||
const scanQueueSize = 200000
|
||||
|
||||
type ScanJob struct {
|
||||
txnManager models.TransactionManager
|
||||
txnManager models.Repository
|
||||
input ScanMetadataInput
|
||||
subscriptions *subscriptionManager
|
||||
}
|
||||
@@ -220,20 +220,21 @@ func (j *ScanJob) doesPathExist(ctx context.Context, path string) bool {
|
||||
gExt := config.GetGalleryExtensions()
|
||||
|
||||
ret := false
|
||||
txnErr := j.txnManager.WithReadTxn(ctx, func(r models.ReaderRepository) error {
|
||||
txnErr := j.txnManager.WithTxn(ctx, func(ctx context.Context) error {
|
||||
r := j.txnManager
|
||||
switch {
|
||||
case fsutil.MatchExtension(path, gExt):
|
||||
g, _ := r.Gallery().FindByPath(path)
|
||||
g, _ := r.Gallery.FindByPath(ctx, path)
|
||||
if g != nil {
|
||||
ret = true
|
||||
}
|
||||
case fsutil.MatchExtension(path, vidExt):
|
||||
s, _ := r.Scene().FindByPath(path)
|
||||
s, _ := r.Scene.FindByPath(ctx, path)
|
||||
if s != nil {
|
||||
ret = true
|
||||
}
|
||||
case fsutil.MatchExtension(path, imgExt):
|
||||
i, _ := r.Image().FindByPath(path)
|
||||
i, _ := r.Image.FindByPath(ctx, path)
|
||||
if i != nil {
|
||||
ret = true
|
||||
}
|
||||
@@ -249,7 +250,7 @@ func (j *ScanJob) doesPathExist(ctx context.Context, path string) bool {
|
||||
}
|
||||
|
||||
type ScanTask struct {
|
||||
TxnManager models.TransactionManager
|
||||
TxnManager models.Repository
|
||||
file file.SourceFile
|
||||
UseFileMetadata bool
|
||||
StripFileExtension bool
|
||||
|
||||
Reference in New Issue
Block a user