fix:优化图片缩放

This commit is contained in:
momo 2023-09-01 11:38:24 +08:00
parent aa4a48b68a
commit 4d443e9cc3

View File

@ -61,7 +61,7 @@ func (d *defaultResource) UpdateMetadata(ctx context.Context, in *UpdateMetadata
return err return err
} }
var newResourceMetadata string var newResourceMetadata string
if oldResource.Metadata != nil && *oldResource.Metadata != "{}" { if oldResource.Metadata != nil && *oldResource.Metadata != "{}" && *oldResource.Metadata != "" {
var oldResourceMetadata map[string]interface{} var oldResourceMetadata map[string]interface{}
err = json.Unmarshal([]byte(*oldResource.Metadata), &oldResourceMetadata) err = json.Unmarshal([]byte(*oldResource.Metadata), &oldResourceMetadata)
if err != nil { if err != nil {
@ -72,8 +72,8 @@ func (d *defaultResource) UpdateMetadata(ctx context.Context, in *UpdateMetadata
switch val := v.(type) { switch val := v.(type) {
case map[string]interface{}: case map[string]interface{}:
oldResourceMetadataData := oldResourceMetadata[k].(map[string]interface{}) oldResourceMetadataData := oldResourceMetadata[k].(map[string]interface{})
for key := range val { for key, val1 := range val {
oldResourceMetadataData[key] = val oldResourceMetadataData[key] = val1
} }
oldResourceMetadata[k] = oldResourceMetadataData oldResourceMetadata[k] = oldResourceMetadataData
} }
@ -90,8 +90,8 @@ func (d *defaultResource) UpdateMetadata(ctx context.Context, in *UpdateMetadata
switch val := v.(type) { switch val := v.(type) {
case map[string]interface{}: case map[string]interface{}:
var resourceMetadataData = make(map[string]interface{}, len(val)) var resourceMetadataData = make(map[string]interface{}, len(val))
for key := range val { for key, val1 := range val {
resourceMetadataData[key] = val resourceMetadataData[key] = val1
} }
resourceMetadata[k] = resourceMetadataData resourceMetadata[k] = resourceMetadataData
} }