Skip to content

Commit

Permalink
fix: panic makeslice len out of range
Browse files Browse the repository at this point in the history
Resolve BE-2133
  • Loading branch information
nickpetrovic committed Jan 11, 2025
1 parent 3a39a05 commit 29748ce
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/abstractions/volume/multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ func (s *GlobalVolumeService) CreateMultipartUpload(ctx context.Context, in *pb.
}

totalParts := math.Ceil(float64(in.FileSize) / float64(in.ChunkSize))
uploadParts := make([]*pb.FileUploadPart, int(totalParts))

// When the file size is 0, we still need to create a part
if len(uploadParts) == 0 {
uploadParts = make([]*pb.FileUploadPart, 1)
if in.FileSize == 0 && in.ChunkSize == 0 {
// When file and chunk size are both 0, we assume that the file is empty
totalParts = 1
}
uploadParts := make([]*pb.FileUploadPart, int(totalParts))

for i := range uploadParts {
res, err := s.CreatePresignedURL(ctx, &pb.CreatePresignedURLRequest{
Expand Down

0 comments on commit 29748ce

Please sign in to comment.