mirror of https://github.com/stashapp/stash.git
Fix bulk add movie to scenes and autotag transaction error (#2928)
* Fix bulk add movie to scene * Fix already in transaction error for autotag
This commit is contained in:
parent
648247aa00
commit
0359ce2ed8
|
@ -228,7 +228,7 @@ func (r *mutationResolver) BulkSceneUpdate(ctx context.Context, input BulkSceneU
|
|||
}
|
||||
|
||||
// Save the movies
|
||||
if translator.hasField("movies") {
|
||||
if translator.hasField("movie_ids") {
|
||||
updatedScene.MovieIDs, err = translateSceneMovieIDs(*input.MovieIds)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("converting movie ids: %w", err)
|
||||
|
|
|
@ -66,6 +66,10 @@ func (r *Repository) WithTxn(ctx context.Context, fn txn.TxnFunc) error {
|
|||
return txn.WithTxn(ctx, r, fn)
|
||||
}
|
||||
|
||||
func (r *Repository) WithDB(ctx context.Context, fn txn.TxnFunc) error {
|
||||
return txn.WithDatabase(ctx, r, fn)
|
||||
}
|
||||
|
||||
func sqliteRepository(d *sqlite.Database) Repository {
|
||||
txnRepo := d.TxnRepository()
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ func (j *autoTagJob) autoTagPerformers(ctx context.Context, progress *job.Progre
|
|||
for _, performerId := range performerIds {
|
||||
var performers []*models.Performer
|
||||
|
||||
if err := j.txnManager.WithTxn(ctx, func(ctx context.Context) error {
|
||||
if err := j.txnManager.WithDB(ctx, func(ctx context.Context) error {
|
||||
performerQuery := j.txnManager.Performer
|
||||
ignoreAutoTag := false
|
||||
perPage := -1
|
||||
|
@ -200,7 +200,7 @@ func (j *autoTagJob) autoTagStudios(ctx context.Context, progress *job.Progress,
|
|||
for _, studioId := range studioIds {
|
||||
var studios []*models.Studio
|
||||
|
||||
if err := r.WithTxn(ctx, func(ctx context.Context) error {
|
||||
if err := r.WithDB(ctx, func(ctx context.Context) error {
|
||||
studioQuery := r.Studio
|
||||
ignoreAutoTag := false
|
||||
perPage := -1
|
||||
|
@ -279,7 +279,7 @@ func (j *autoTagJob) autoTagTags(ctx context.Context, progress *job.Progress, pa
|
|||
|
||||
for _, tagId := range tagIds {
|
||||
var tags []*models.Tag
|
||||
if err := j.txnManager.WithTxn(ctx, func(ctx context.Context) error {
|
||||
if err := j.txnManager.WithDB(ctx, func(ctx context.Context) error {
|
||||
tagQuery := r.Tag
|
||||
ignoreAutoTag := false
|
||||
perPage := -1
|
||||
|
|
|
@ -791,6 +791,29 @@ func Test_sceneQueryBuilder_UpdatePartialRelationships(t *testing.T) {
|
|||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"add movies to empty",
|
||||
sceneIDs[sceneIdx1WithPerformer],
|
||||
models.ScenePartial{
|
||||
MovieIDs: &models.UpdateMovieIDs{
|
||||
Movies: movieScenes,
|
||||
Mode: models.RelationshipUpdateModeAdd,
|
||||
},
|
||||
},
|
||||
models.Scene{
|
||||
Movies: models.NewRelatedMovies([]models.MoviesScenes{
|
||||
{
|
||||
MovieID: movieIDs[movieIdxWithDupName],
|
||||
SceneIndex: &sceneIndex,
|
||||
},
|
||||
{
|
||||
MovieID: movieIDs[movieIdxWithStudio],
|
||||
SceneIndex: &sceneIndex2,
|
||||
},
|
||||
}),
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"add stash ids",
|
||||
sceneIDs[sceneIdxWithSpacedName],
|
||||
|
|
|
@ -442,11 +442,16 @@ func (t *scenesMoviesTable) addJoins(ctx context.Context, id int, v []models.Mov
|
|||
// only add values that are not already present
|
||||
var filtered []models.MoviesScenes
|
||||
for _, vv := range v {
|
||||
found := false
|
||||
|
||||
for _, e := range fks {
|
||||
if vv.MovieID == e.MovieID {
|
||||
continue
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
filtered = append(filtered, vv)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue