Skip to content

Commit

Permalink
fix empty upload (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 authored Dec 5, 2023
1 parent f2d30c5 commit 2a794a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 1 addition & 7 deletions zboxcore/sdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,7 @@ func (a *Allocation) StartMultiUpload(workdir string, localPaths []string, fileN
Workdir: workdir,
RemotePath: fileMeta.RemotePath,
}
if fileMeta.ActualSize == 0 {
byteReader := bytes.NewReader([]byte(
emptyFileDataHash))
operationRequests[idx].FileReader = byteReader
operationRequests[idx].Opts = append(operationRequests[idx].Opts, WithActualHash(emptyFileDataHash))
operationRequests[idx].FileMeta.ActualSize = int64(len(emptyFileDataHash))
}

if isUpdate[idx] {
operationRequests[idx].OperationType = constants.FileOperationUpdate
}
Expand Down
8 changes: 8 additions & 0 deletions zboxcore/sdk/upload_worker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sdk

import (
"bytes"
"io"

thrown "github.com/0chain/errors"
Expand Down Expand Up @@ -118,6 +119,13 @@ func (uo *UploadOperation) Error(allocObj *Allocation, consensus int, err error)

func NewUploadOperation(workdir string, allocObj *Allocation, connectionID string, fileMeta FileMeta, fileReader io.Reader, isUpdate, isWebstreaming bool, opts ...ChunkedUploadOption) (*UploadOperation, string, error) {
uo := &UploadOperation{}
if fileMeta.ActualSize == 0 {
byteReader := bytes.NewReader([]byte(
emptyFileDataHash))
fileReader = byteReader
opts = append(opts, WithActualHash(emptyFileDataHash))
fileMeta.ActualSize = int64(len(emptyFileDataHash))
}
cu, err := CreateChunkedUpload(workdir, allocObj, fileMeta, fileReader, isUpdate, false, isWebstreaming, connectionID, opts...)
if err != nil {
return nil, "", err
Expand Down

0 comments on commit 2a794a0

Please sign in to comment.