Fix checksum during studio/performer update

This commit is contained in:
WithoutPants
2019-08-22 12:49:09 +10:00
parent 7f276cb331
commit 2b35d4e706
2 changed files with 9 additions and 4 deletions

View File

@@ -111,15 +111,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}

View File

@@ -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}