From 03c906271cb765b14a13672990fc905a5dc81e2b Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Fri, 8 Mar 2024 14:11:31 +0800 Subject: [PATCH] fix doesn't unlock shadow-object balance when a bucket is force deleted --- x/storage/keeper/keeper.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index d4e2fe06a..4bf6e94c2 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -341,6 +341,15 @@ func (k Keeper) ForceDeleteBucket(ctx sdk.Context, bucketId sdkmath.Uint, cap ui return false, deleted, err } k.SetInternalBucketInfo(ctx, bucketInfo.Id, internalBucketInfo) + + // if an object is updating, also need to unlock the shadowObject fee + if objectInfo.IsUpdating { + shadowObjectInfo := k.MustGetShadowObjectInfo(ctx, bucketInfo.BucketName, objectInfo.ObjectName) + err = k.UnlockShadowObjectFeeAndDeleteShadowObjectInfo(ctx, bucketInfo, shadowObjectInfo, objectInfo.ObjectName) + if err != nil { + return false, deleted, err + } + } } if err := k.doDeleteObject(ctx, spOperatorAddr, bucketInfo, &objectInfo); err != nil { ctx.Logger().Error("do delete object err", "err", err)