Skip to content

Commit 51e4837

Browse files
authored
Merge pull request #1562 from 0chain/hotfix/recover-ops
Add recover to file ops
2 parents 6b68d45 + 24e6821 commit 51e4837

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

wasmsdk/blobber.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ import (
3131
const FileOperationInsert = "insert"
3232

3333
func listObjects(allocationID string, remotePath string, offset, pageLimit int) (*sdk.ListResult, error) {
34+
defer func() {
35+
if r := recover(); r != nil {
36+
PrintError("Recovered in listObjects Error", r)
37+
}
38+
}()
3439
alloc, err := getAllocation(allocationID)
3540
if err != nil {
3641
return nil, err
@@ -370,6 +375,11 @@ func Share(allocationID, remotePath, clientID, encryptionPublicKey string, expir
370375
// - error
371376

372377
func multiDownload(allocationID, jsonMultiDownloadOptions, authTicket, callbackFuncName string) (string, error) {
378+
defer func() {
379+
if r := recover(); r != nil {
380+
PrintError("Recovered in multiDownload Error", r)
381+
}
382+
}()
373383
sdkLogger.Info("starting multidownload")
374384
wg := &sync.WaitGroup{}
375385
useCallback := false
@@ -609,6 +619,11 @@ func setUploadMode(mode int) {
609619
}
610620

611621
func multiUpload(jsonBulkUploadOptions string) (MultiUploadResult, error) {
622+
defer func() {
623+
if r := recover(); r != nil {
624+
PrintError("Recovered in multiupload Error", r)
625+
}
626+
}()
612627
var options []BulkUploadOption
613628
result := MultiUploadResult{}
614629
err := json.Unmarshal([]byte(jsonBulkUploadOptions), &options)

wasmsdk/proxy.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ func main() {
5151
if !(jsSign.IsNull() || jsSign.IsUndefined()) {
5252
signFunc := func(hash string) (string, error) {
5353
c := client.GetClient()
54+
if c == nil || len(c.Keys) == 0 {
55+
return "", errors.New("no keys found")
56+
}
5457
pk := c.Keys[0].PrivateKey
5558
result, err := jsbridge.Await(jsSign.Invoke(hash, pk))
5659

@@ -237,7 +240,7 @@ func main() {
237240

238241
"decodeAuthTicket": decodeAuthTicket,
239242
"allocationRepair": allocationRepair,
240-
"repairSize": repairSize,
243+
"repairSize": repairSize,
241244

242245
//smartcontract
243246
"executeSmartContract": executeSmartContract,

zboxcore/sdk/downloadworker.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ func (req *DownloadRequest) processDownload() {
449449
return
450450
}
451451
req.fileHandler.Sync() //nolint
452+
if req.statusCallback != nil && !req.skip {
453+
req.statusCallback.Completed(
454+
req.allocationID, remotePathCB, fRef.Name, fRef.MimeType, 32, op)
455+
}
452456
return
453457
}
454458
size, chunksPerShard, blocksPerShard := req.size, req.chunksPerShard, req.blocksPerShard

0 commit comments

Comments
 (0)