mirror of https://github.com/stashapp/stash.git
Merge branch 'optional_performer_image' of https://github.com/WithoutPants/stash into optional_performer_image
This commit is contained in:
commit
486e146fff
|
@ -112,15 +112,18 @@ func (r *mutationResolver) PerformerUpdate(ctx context.Context, input models.Per
|
||||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: time.Now()},
|
UpdatedAt: models.SQLiteTimestamp{Timestamp: time.Now()},
|
||||||
}
|
}
|
||||||
if input.Image != nil {
|
if input.Image != nil {
|
||||||
checksum, imageData, err := utils.ProcessBase64Image(*input.Image)
|
_, imageData, err := utils.ProcessBase64Image(*input.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
updatedPerformer.Image = imageData
|
updatedPerformer.Image = imageData
|
||||||
updatedPerformer.Checksum = checksum
|
|
||||||
}
|
}
|
||||||
if input.Name != nil {
|
if input.Name != nil {
|
||||||
|
// generate checksum from performer name rather than image
|
||||||
|
checksum := utils.MD5FromString(*input.Name)
|
||||||
|
|
||||||
updatedPerformer.Name = sql.NullString{String: *input.Name, Valid: true}
|
updatedPerformer.Name = sql.NullString{String: *input.Name, Valid: true}
|
||||||
|
updatedPerformer.Checksum = checksum
|
||||||
}
|
}
|
||||||
if input.URL != nil {
|
if input.URL != nil {
|
||||||
updatedPerformer.URL = sql.NullString{String: *input.URL, Valid: true}
|
updatedPerformer.URL = sql.NullString{String: *input.URL, Valid: true}
|
||||||
|
|
|
@ -66,15 +66,17 @@ func (r *mutationResolver) StudioUpdate(ctx context.Context, input models.Studio
|
||||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: time.Now()},
|
UpdatedAt: models.SQLiteTimestamp{Timestamp: time.Now()},
|
||||||
}
|
}
|
||||||
if input.Image != nil {
|
if input.Image != nil {
|
||||||
checksum, imageData, err := utils.ProcessBase64Image(*input.Image)
|
_, imageData, err := utils.ProcessBase64Image(*input.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
updatedStudio.Image = imageData
|
updatedStudio.Image = imageData
|
||||||
updatedStudio.Checksum = checksum
|
|
||||||
}
|
}
|
||||||
if input.Name != nil {
|
if input.Name != nil {
|
||||||
|
// generate checksum from studio name rather than image
|
||||||
|
checksum := utils.MD5FromString(*input.Name)
|
||||||
updatedStudio.Name = sql.NullString{String: *input.Name, Valid: true}
|
updatedStudio.Name = sql.NullString{String: *input.Name, Valid: true}
|
||||||
|
updatedStudio.Checksum = checksum
|
||||||
}
|
}
|
||||||
if input.URL != nil {
|
if input.URL != nil {
|
||||||
updatedStudio.URL = sql.NullString{String: *input.URL, Valid: true}
|
updatedStudio.URL = sql.NullString{String: *input.URL, Valid: true}
|
||||||
|
|
|
@ -64,8 +64,11 @@ func (t *ImportTask) ImportPerformers(ctx context.Context) {
|
||||||
|
|
||||||
logger.Progressf("[performers] %d of %d", index, len(t.Mappings.Performers))
|
logger.Progressf("[performers] %d of %d", index, len(t.Mappings.Performers))
|
||||||
|
|
||||||
|
// generate checksum from performer name rather than image
|
||||||
|
checksum := utils.MD5FromString(performerJSON.Name)
|
||||||
|
|
||||||
// Process the base 64 encoded image string
|
// Process the base 64 encoded image string
|
||||||
checksum, imageData, err := utils.ProcessBase64Image(performerJSON.Image)
|
_, imageData, err := utils.ProcessBase64Image(performerJSON.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = tx.Rollback()
|
_ = tx.Rollback()
|
||||||
logger.Errorf("[performers] <%s> invalid image: %s", mappingJSON.Checksum, err.Error())
|
logger.Errorf("[performers] <%s> invalid image: %s", mappingJSON.Checksum, err.Error())
|
||||||
|
@ -159,8 +162,11 @@ func (t *ImportTask) ImportStudios(ctx context.Context) {
|
||||||
|
|
||||||
logger.Progressf("[studios] %d of %d", index, len(t.Mappings.Studios))
|
logger.Progressf("[studios] %d of %d", index, len(t.Mappings.Studios))
|
||||||
|
|
||||||
|
// generate checksum from studio name rather than image
|
||||||
|
checksum := utils.MD5FromString(studioJSON.Name)
|
||||||
|
|
||||||
// Process the base 64 encoded image string
|
// Process the base 64 encoded image string
|
||||||
checksum, imageData, err := utils.ProcessBase64Image(studioJSON.Image)
|
_, imageData, err := utils.ProcessBase64Image(studioJSON.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = tx.Rollback()
|
_ = tx.Rollback()
|
||||||
logger.Errorf("[studios] <%s> invalid image: %s", mappingJSON.Checksum, err.Error())
|
logger.Errorf("[studios] <%s> invalid image: %s", mappingJSON.Checksum, err.Error())
|
||||||
|
|
Loading…
Reference in New Issue