Genericise sliceutil functions (#4253)

* Genericise sliceutil.SliceSame
* Genericise intslice functions
* Genericise stringutil functions
This commit is contained in:
DingDongSoLong4
2023-11-01 23:58:32 +02:00
committed by GitHub
parent cc6673f276
commit 9621213424
51 changed files with 259 additions and 409 deletions

View File

@@ -7,7 +7,7 @@ import (
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/models/jsonschema"
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
"github.com/stashapp/stash/pkg/sliceutil"
)
type GalleryFinder interface {
@@ -229,8 +229,8 @@ func (i *Importer) populatePerformers(ctx context.Context) error {
pluckedNames = append(pluckedNames, performer.Name)
}
missingPerformers := stringslice.StrFilter(names, func(name string) bool {
return !stringslice.StrInclude(pluckedNames, name)
missingPerformers := sliceutil.Filter(names, func(name string) bool {
return !sliceutil.Contains(pluckedNames, name)
})
if len(missingPerformers) > 0 {
@@ -365,8 +365,8 @@ func importTags(ctx context.Context, tagWriter models.TagFinderCreator, names []
pluckedNames = append(pluckedNames, tag.Name)
}
missingTags := stringslice.StrFilter(names, func(name string) bool {
return !stringslice.StrInclude(pluckedNames, name)
missingTags := sliceutil.Filter(names, func(name string) bool {
return !sliceutil.Contains(pluckedNames, name)
})
if len(missingTags) > 0 {

View File

@@ -11,7 +11,7 @@ import (
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/models/paths"
"github.com/stashapp/stash/pkg/plugin"
"github.com/stashapp/stash/pkg/sliceutil/intslice"
"github.com/stashapp/stash/pkg/sliceutil"
"github.com/stashapp/stash/pkg/txn"
)
@@ -355,7 +355,7 @@ func (h *ScanHandler) getGalleryToAssociate(ctx context.Context, newImage *model
return nil, err
}
if g != nil && !intslice.IntInclude(newImage.GalleryIDs.List(), g.ID) {
if g != nil && !sliceutil.Contains(newImage.GalleryIDs.List(), g.ID) {
return g, nil
}