Skip to content

Commit

Permalink
copy from file
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 committed Aug 19, 2023
1 parent df045f7 commit bacc62a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions code/go/0chain.net/blobbercore/filestore/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,19 @@ func (fs *FileStore) WriteFile(allocID, conID string, fileData *FileInputData, i
return nil, common.NewError("file_seek_error", err.Error())
}
buf := make([]byte, BufferSize)
_, err = io.CopyBuffer(fileData.Hasher, infile, buf)
writtenSize, err := io.CopyBuffer(f, infile, buf)
if err != nil {
return nil, common.NewError("file_read_error", err.Error())
return nil, common.NewError("file_write_error", err.Error())
}
_, err = infile.Seek(0, io.SeekStart)

_, err = f.Seek(fileData.UploadOffset, io.SeekStart)
if err != nil {
return nil, common.NewError("file_seek_error", err.Error())
}

writtenSize, err := io.CopyBuffer(f, infile, buf)
_, err = io.CopyBuffer(fileData.Hasher, f, buf)
if err != nil {
return nil, common.NewError("file_write_error", err.Error())
return nil, common.NewError("file_read_error", err.Error())
}

finfo, err = f.Stat()
Expand Down
4 changes: 4 additions & 0 deletions code/go/0chain.net/blobbercore/filestore/tree_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ func GetNewCommitHasher(dataSize int64) *CommitHasher {
}

func (c *CommitHasher) Write(b []byte) (int, error) {
if !c.isInitialized || c.fmt == nil || c.vt == nil {
return 0, errors.New("commit hasher is not initialized")
}

var (
wg sync.WaitGroup
errChan = make(chan error, 2)
Expand Down

0 comments on commit bacc62a

Please sign in to comment.