Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List dir for v2 and pool for shards in workers #1708

Draft
wants to merge 5 commits into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions zboxcore/sdk/chunked_upload_process_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type ChunkedUploadFormInfo struct {
StorageVersion int
EncryptionVersion int
PrivateSigningKey ed25519.PrivateKey
bbuf *bytebufferpool.ByteBuffer
}

// createUploadProgress create a new UploadProgress
Expand Down Expand Up @@ -463,6 +464,7 @@ func ProcessEventData(data safejs.Value) {
formBuilder := CreateChunkedUploadFormBuilder(formInfo.StorageVersion, formInfo.EncryptionVersion, formInfo.PrivateSigningKey)
uploadData, err := formBuilder.Build(fileMeta, wp.hasher, formInfo.ConnectionID, blobberID, formInfo.ChunkSize, formInfo.ChunkStartIndex, formInfo.ChunkEndIndex, formInfo.IsFinal, formInfo.EncryptedKey, formInfo.EncryptedKeyPoint,
fileShards, thumbnailChunkData, formInfo.ShardSize)
uploadPool.Put(formInfo.bbuf)
if err != nil {
selfPostMessage(false, false, err.Error(), remotePath, formInfo.ChunkEndIndex, nil)
return
Expand Down Expand Up @@ -599,9 +601,15 @@ func parseEventData(data safejs.Value) (*FileMeta, *ChunkedUploadFormInfo, [][]b
if err != nil {
return nil, nil, nil, nil, err
}
buf := make([]byte, fileShardLen)
safejs.CopyBytesToGo(buf, fileShardUint8)
fileShards := splitData(buf, int(chunkSize))
bbuf := uploadPool.Get()
if cap(bbuf.B) < fileShardLen {
bbuf.B = make([]byte, fileShardLen)
} else {
bbuf.B = bbuf.B[:fileShardLen]
}
safejs.CopyBytesToGo(bbuf.B, fileShardUint8)
fileShards := splitData(bbuf.B, int(chunkSize))
formInfo.bbuf = bbuf
fileShardUint8.Set("buffer", js.Null())
formInfoUint8.Set("buffer", js.Null())
fileMetaUint8.Set("buffer", js.Null())
Expand Down
5 changes: 4 additions & 1 deletion zboxcore/sdk/listworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ func (req *ListRequest) getlistFromBlobbers() ([]*listResponse, error) {
for i := 0; i < numList; i++ {
go req.getListInfoFromBlobber(req.blobbers[i], i, rspCh)
}
if req.storageVersion == StorageV2 {
req.listOnly = true
}
listInfos := make([]*listResponse, numList)
consensusMap := make(map[string][]*blockchain.StorageNode)
var consensusHash string
Expand Down Expand Up @@ -241,7 +244,7 @@ func (req *ListRequest) GetListFromBlobbers() (*ListResult, error) {
}
selected := make(map[string]*ListResult)
childResultMap := make(map[string]*ListResult)
if !req.forRepair {
if !req.forRepair && req.storageVersion == 0 {
req.consensusThresh = 1
}
for i := 0; i < len(lR); i++ {
Expand Down
Loading