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

Wasm for move, rename, copy #1233

Merged
merged 3 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 23 additions & 6 deletions wasmsdk/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ <h2>please download zcn.wasm from https://github.com/0chain/gosdk/releases/lates
}
})
}
const results = await goWasm.multiUpload(objects)
const results = await goWasm.bulkUpload(objects)
console.log(JSON.stringify(results))
}
})
Expand Down Expand Up @@ -810,16 +810,33 @@ <h2>please download zcn.wasm from https://github.com/0chain/gosdk/releases/lates
}
const objects = []

objects.push({
objects.push(
{ // rename file
operationType: `move`,
remotePath: `/zcn.wasm`,
destPath: `/folder1`,
})
remotePath: `/small2-182b.txt`,
destPath: `/folder/small-182b.txt`,
},
{ // todo: rename folder
operationType: `move`,
remotePath: `/folder`,
destPath: `/folder2`,
},
{ // move a file to an other folder
operationType: `move`,
remotePath: `/small-182b.txt`,
destPath: `/folder/`,
},
{ // copy a file to an other folder
operationType: `copy`,
remotePath: `/small2-182b.txt`,
destPath: `/folder/`,
},
)

let stringifiedArray = JSON.stringify(objects);

try {
console.log("execting", objects[0])
console.log("executing MultiOps", objects[0])
const output = await goWasm.sdk.multiOperation(allocationId, stringifiedArray)
} catch (e) {
alert(e)
Expand Down
2 changes: 0 additions & 2 deletions zboxcore/sdk/chunked_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ func (su *ChunkedUpload) process() error {

//chunk has not be uploaded yet
if chunks.chunkEndIndex > su.progress.ChunkIndex {
start := time.Now()
err = su.processUpload(
chunks.chunkStartIndex, chunks.chunkEndIndex,
chunks.fileShards, chunks.thumbnailShards,
Expand All @@ -494,7 +493,6 @@ func (su *ChunkedUpload) process() error {
}
return err
}
logger.Logger.Info("[processUpload]", time.Since(start).Milliseconds())
} else {
// Write data to hashers
for i, blobberShard := range chunks.fileShards {
Expand Down
2 changes: 0 additions & 2 deletions zboxcore/sdk/chunked_upload_blobber.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ func (sb *ChunkedUploadBlobber) sendUploadRequest(
for i := 0; i < 3; i++ {
err, shouldContinue = func() (err error, shouldContinue bool) {
reqCtx, ctxCncl := context.WithTimeout(ctx, su.uploadTimeOut)
start := time.Now()
var resp *http.Response
err = zboxutil.HttpDo(reqCtx, ctxCncl, req, func(r *http.Response, err error) error {
resp = r
return err
})
defer ctxCncl()
logger.Logger.Info("[sendUploadRequestBlobber] ", time.Since(start).Milliseconds())

if err != nil {
logger.Logger.Error("Upload : ", err)
Expand Down
4 changes: 0 additions & 4 deletions zboxcore/sdk/chunked_upload_form_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (
"io"
"mime/multipart"
"sync"
"time"

"github.com/0chain/gosdk/zboxcore/client"
"github.com/0chain/gosdk/zboxcore/logger"

"golang.org/x/crypto/sha3"
)
Expand Down Expand Up @@ -109,7 +107,6 @@ func (b *chunkedUploadFormBuilder) Build(

metadata.FileBytesLen += len(chunkBytes)
}
start := time.Now()
if isFinal {
err = hasher.Finalize()
if err != nil {
Expand Down Expand Up @@ -140,7 +137,6 @@ func (b *chunkedUploadFormBuilder) Build(
for err := range errChan {
return nil, metadata, err
}
logger.Logger.Info("[hasherTime]", time.Since(start).Milliseconds())
actualHashSignature, err := client.Sign(fileMeta.ActualHash)
if err != nil {
return nil, metadata, err
Expand Down