Skip to content

Commit

Permalink
Fixing create object method (#856)
Browse files Browse the repository at this point in the history
* Fixing CreateObject Method

* resolving comments

* fixing generation condition

* fixing generation condition
  • Loading branch information
Tulsishah committed Dec 21, 2022
1 parent 18b9763 commit 66744d7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/storage/bucket_handle.go
Expand Up @@ -108,14 +108,14 @@ func (bh *bucketHandle) CreateObject(ctx context.Context, req *gcs.CreateObjectR
// GenerationPrecondition - If non-nil, the object will be created/overwritten
// only if the current generation for the object name is equal to the given value.
// Zero means the object does not exist.
if req.GenerationPrecondition != nil && *req.GenerationPrecondition != 0 {
obj = obj.If(storage.Conditions{GenerationMatch: *req.GenerationPrecondition})
}

// MetaGenerationPrecondition - If non-nil, the object will be created/overwritten
// only if the current metaGeneration for the object name is equal to the given value.
// Zero means the object does not exist.
if req.MetaGenerationPrecondition != nil && *req.MetaGenerationPrecondition != 0 {
if req.GenerationPrecondition != nil && *req.GenerationPrecondition != 0 && req.MetaGenerationPrecondition != nil && *req.MetaGenerationPrecondition != 0 {
obj = obj.If(storage.Conditions{GenerationMatch: *req.GenerationPrecondition, MetagenerationMatch: *req.MetaGenerationPrecondition})
} else if req.GenerationPrecondition != nil && *req.GenerationPrecondition != 0 {
obj = obj.If(storage.Conditions{GenerationMatch: *req.GenerationPrecondition})
} else if req.MetaGenerationPrecondition != nil && *req.MetaGenerationPrecondition != 0 {
obj = obj.If(storage.Conditions{MetagenerationMatch: *req.MetaGenerationPrecondition})
}

Expand Down

0 comments on commit 66744d7

Please sign in to comment.