Skip to content

Commit

Permalink
Merge pull request #587 from alexgao001/fix-discontinue-unlock-shadow…
Browse files Browse the repository at this point in the history
…object

fix: disallow copy an object is being updated
  • Loading branch information
KeefeL committed Mar 11, 2024
2 parents a74e009 + fa7bf52 commit 164ef7e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,9 @@ func (k Keeper) SealObject(
prevCheckSums := objectInfo.Checksums

isUpdate := objectInfo.IsUpdating
if isUpdate {

// an object might be set to OBJECT_STATUS_DISCONTINUED
if isUpdate && objectInfo.ObjectStatus == types.OBJECT_STATUS_SEALED {
internalBucketInfo := k.MustGetInternalBucketInfo(ctx, bucketInfo.Id)
err := k.UnChargeObjectStoreFee(ctx, bucketInfo, internalBucketInfo, objectInfo)
if err != nil {
Expand Down Expand Up @@ -1151,6 +1153,10 @@ func (k Keeper) CopyObject(
return sdkmath.ZeroUint(), types.ErrSourceTypeMismatch
}

if srcObjectInfo.IsUpdating {
return sdkmath.ZeroUint(), types.ErrAccessDenied.Wrapf("the object is being updated, can not be copied")
}

// check permission
effect := k.VerifyObjectPermission(ctx, srcBucketInfo, srcObjectInfo, operator, permtypes.ACTION_COPY_OBJECT)
if effect != permtypes.EFFECT_ALLOW {
Expand Down

0 comments on commit 164ef7e

Please sign in to comment.