Skip to content

Commit 25d9a38

Browse files
committed
add log for update custom meta
1 parent c55b75e commit 25d9a38

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

code/go/0chain.net/blobbercore/handler/object_operation_handler.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,8 +1261,13 @@ func (fsh *StorageHandler) CreateDir(ctx context.Context, r *http.Request) (*all
12611261
// target directory exists, return StatusOK
12621262
if exisitingRef.Type == reference.DIRECTORY {
12631263
if exisitingRef.CustomMeta != customMeta {
1264+
logging.Logger.Info("Updating custom meta", zap.String("path", exisitingRef.Path))
12641265
_ = datastore.GetStore().WithNewTransaction(func(ctx context.Context) error {
1265-
return reference.UpdateCustomMeta(ctx, exisitingRef.ID, customMeta)
1266+
err := reference.UpdateCustomMeta(ctx, exisitingRef, customMeta)
1267+
if err != nil {
1268+
logging.Logger.Error("Error updating custom meta", zap.Error(err))
1269+
}
1270+
return err
12661271
})
12671272
}
12681273
return nil, common.NewError("directory_exists", "Directory already exists`")

code/go/0chain.net/blobbercore/reference/ref.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ func GetListingFieldsMap(refEntity interface{}, tagName string) map[string]inter
670670
return result
671671
}
672672

673-
func UpdateCustomMeta(ctx context.Context, refID int64, customMeta string) error {
673+
func UpdateCustomMeta(ctx context.Context, ref *Ref, customMeta string) error {
674674
db := datastore.GetStore().GetTransaction(ctx)
675-
return db.Model(&Ref{}).Where("id = ?", refID).Update("custom_meta", customMeta).Error
675+
return db.Model(ref).Update("custom_meta", customMeta).Error
676676
}

0 commit comments

Comments
 (0)