Skip to content

Commit

Permalink
Merge pull request #1562 from 0chain/hotfix/recover-ops
Browse files Browse the repository at this point in the history
Add recover to file ops
  • Loading branch information
dabasov authored Jul 23, 2024
2 parents 6b68d45 + 24e6821 commit 51e4837
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
15 changes: 15 additions & 0 deletions wasmsdk/blobber.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import (
const FileOperationInsert = "insert"

func listObjects(allocationID string, remotePath string, offset, pageLimit int) (*sdk.ListResult, error) {
defer func() {
if r := recover(); r != nil {
PrintError("Recovered in listObjects Error", r)
}
}()
alloc, err := getAllocation(allocationID)
if err != nil {
return nil, err
Expand Down Expand Up @@ -370,6 +375,11 @@ func Share(allocationID, remotePath, clientID, encryptionPublicKey string, expir
// - error

func multiDownload(allocationID, jsonMultiDownloadOptions, authTicket, callbackFuncName string) (string, error) {
defer func() {
if r := recover(); r != nil {
PrintError("Recovered in multiDownload Error", r)
}
}()
sdkLogger.Info("starting multidownload")
wg := &sync.WaitGroup{}
useCallback := false
Expand Down Expand Up @@ -609,6 +619,11 @@ func setUploadMode(mode int) {
}

func multiUpload(jsonBulkUploadOptions string) (MultiUploadResult, error) {
defer func() {
if r := recover(); r != nil {
PrintError("Recovered in multiupload Error", r)
}
}()
var options []BulkUploadOption
result := MultiUploadResult{}
err := json.Unmarshal([]byte(jsonBulkUploadOptions), &options)
Expand Down
5 changes: 4 additions & 1 deletion wasmsdk/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func main() {
if !(jsSign.IsNull() || jsSign.IsUndefined()) {
signFunc := func(hash string) (string, error) {
c := client.GetClient()
if c == nil || len(c.Keys) == 0 {
return "", errors.New("no keys found")
}
pk := c.Keys[0].PrivateKey
result, err := jsbridge.Await(jsSign.Invoke(hash, pk))

Expand Down Expand Up @@ -237,7 +240,7 @@ func main() {

"decodeAuthTicket": decodeAuthTicket,
"allocationRepair": allocationRepair,
"repairSize": repairSize,
"repairSize": repairSize,

//smartcontract
"executeSmartContract": executeSmartContract,
Expand Down
4 changes: 4 additions & 0 deletions zboxcore/sdk/downloadworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ func (req *DownloadRequest) processDownload() {
return
}
req.fileHandler.Sync() //nolint
if req.statusCallback != nil && !req.skip {
req.statusCallback.Completed(
req.allocationID, remotePathCB, fRef.Name, fRef.MimeType, 32, op)
}
return
}
size, chunksPerShard, blocksPerShard := req.size, req.chunksPerShard, req.blocksPerShard
Expand Down

0 comments on commit 51e4837

Please sign in to comment.