Merge branch 'optional_performer_image' of https://github.com/WithoutPants/stash into optional_performer_image

This commit is contained in:
WithoutPants 2019-08-24 17:17:40 +10:00
commit 486e146fff
3 changed files with 17 additions and 6 deletions

View File

@ -112,15 +112,18 @@ func (r *mutationResolver) PerformerUpdate(ctx context.Context, input models.Per
UpdatedAt: models.SQLiteTimestamp{Timestamp: time.Now()},
}
if input.Image != nil {
checksum, imageData, err := utils.ProcessBase64Image(*input.Image)
_, imageData, err := utils.ProcessBase64Image(*input.Image)
if err != nil {
return nil, err
}
updatedPerformer.Image = imageData
updatedPerformer.Checksum = checksum
}
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.Checksum = checksum
}
if input.URL != nil {
updatedPerformer.URL = sql.NullString{String: *input.URL, Valid: true}

View File

@ -66,15 +66,17 @@ func (r *mutationResolver) StudioUpdate(ctx context.Context, input models.Studio
UpdatedAt: models.SQLiteTimestamp{Timestamp: time.Now()},
}
if input.Image != nil {
checksum, imageData, err := utils.ProcessBase64Image(*input.Image)
_, imageData, err := utils.ProcessBase64Image(*input.Image)
if err != nil {
return nil, err
}
updatedStudio.Image = imageData
updatedStudio.Checksum = checksum
}
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.Checksum = checksum
}
if input.URL != nil {
updatedStudio.URL = sql.NullString{String: *input.URL, Valid: true}

View File

@ -64,8 +64,11 @@ func (t *ImportTask) ImportPerformers(ctx context.Context) {
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
checksum, imageData, err := utils.ProcessBase64Image(performerJSON.Image)
_, imageData, err := utils.ProcessBase64Image(performerJSON.Image)
if err != nil {
_ = tx.Rollback()
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))
// generate checksum from studio name rather than image
checksum := utils.MD5FromString(studioJSON.Name)
// Process the base 64 encoded image string
checksum, imageData, err := utils.ProcessBase64Image(studioJSON.Image)
_, imageData, err := utils.ProcessBase64Image(studioJSON.Image)
if err != nil {
_ = tx.Rollback()
logger.Errorf("[studios] <%s> invalid image: %s", mappingJSON.Checksum, err.Error())