mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +03:00
Fix error when creating/updating performer with alias == name (#4443)
* Filter out performer aliases that match the name * Validate when creating/updating performer in stash-box task
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stashapp/stash/pkg/logger"
|
"github.com/stashapp/stash/pkg/logger"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
|
"github.com/stashapp/stash/pkg/performer"
|
||||||
"github.com/stashapp/stash/pkg/scraper/stashbox"
|
"github.com/stashapp/stash/pkg/scraper/stashbox"
|
||||||
"github.com/stashapp/stash/pkg/studio"
|
"github.com/stashapp/stash/pkg/studio"
|
||||||
)
|
)
|
||||||
@@ -155,6 +156,10 @@ func (t *StashBoxBatchTagTask) processMatchedPerformer(ctx context.Context, p *m
|
|||||||
|
|
||||||
partial := p.ToPartial(t.box.Endpoint, excluded, existingStashIDs)
|
partial := p.ToPartial(t.box.Endpoint, excluded, existingStashIDs)
|
||||||
|
|
||||||
|
if err := performer.ValidateUpdate(ctx, t.performer.ID, partial, qb); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := qb.UpdatePartial(ctx, t.performer.ID, partial); err != nil {
|
if _, err := qb.UpdatePartial(ctx, t.performer.ID, partial); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -185,6 +190,10 @@ func (t *StashBoxBatchTagTask) processMatchedPerformer(ctx context.Context, p *m
|
|||||||
err = r.WithTxn(ctx, func(ctx context.Context) error {
|
err = r.WithTxn(ctx, func(ctx context.Context) error {
|
||||||
qb := r.Performer
|
qb := r.Performer
|
||||||
|
|
||||||
|
if err := performer.ValidateCreate(ctx, *newPerformer, qb); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := qb.Create(ctx, newPerformer); err != nil {
|
if err := qb.Create(ctx, newPerformer); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
"github.com/stashapp/stash/pkg/scraper"
|
"github.com/stashapp/stash/pkg/scraper"
|
||||||
"github.com/stashapp/stash/pkg/scraper/stashbox/graphql"
|
"github.com/stashapp/stash/pkg/scraper/stashbox/graphql"
|
||||||
|
"github.com/stashapp/stash/pkg/sliceutil"
|
||||||
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
|
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
|
||||||
"github.com/stashapp/stash/pkg/txn"
|
"github.com/stashapp/stash/pkg/txn"
|
||||||
"github.com/stashapp/stash/pkg/utils"
|
"github.com/stashapp/stash/pkg/utils"
|
||||||
@@ -669,6 +670,12 @@ func performerFragmentToScrapedPerformer(p graphql.PerformerFragment) *models.Sc
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(p.Aliases) > 0 {
|
if len(p.Aliases) > 0 {
|
||||||
|
// #4437 - stash-box may return aliases that are equal to the performer name
|
||||||
|
// filter these out
|
||||||
|
p.Aliases = sliceutil.Filter(p.Aliases, func(s string) bool {
|
||||||
|
return !strings.EqualFold(s, p.Name)
|
||||||
|
})
|
||||||
|
|
||||||
alias := strings.Join(p.Aliases, ", ")
|
alias := strings.Join(p.Aliases, ", ")
|
||||||
sp.Aliases = &alias
|
sp.Aliases = &alias
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user