@@ -110,7 +110,7 @@ func uploadBin(ctx *cli.Context) error {
110
110
return cli .Exit (fmt .Errorf ("failed to find objects: %w" , err ), 1 )
111
111
}
112
112
113
- err = uploadBlocksAndIndexFiles (ctx , pWrapper , rpc , signer , containerID , user . NewFromScriptHash ( acc . ScriptHash ()), attr , indexAttrKey , buf , i , indexFileSize , uint (currentBlockHeight ), numWorkers , maxRetries , debug )
113
+ err = uploadBlocksAndIndexFiles (ctx , pWrapper , rpc , signer , containerID , attr , indexAttrKey , buf , i , indexFileSize , uint (currentBlockHeight ), numWorkers , maxRetries , debug )
114
114
if err != nil {
115
115
return cli .Exit (fmt .Errorf ("failed to upload objects: %w" , err ), 1 )
116
116
}
@@ -138,7 +138,7 @@ func retry(action func() error, maxRetries uint, debug bool) error {
138
138
}
139
139
140
140
// uploadBlocksAndIndexFiles uploads the blocks and index files to the container using the pool.
141
- func uploadBlocksAndIndexFiles (ctx * cli.Context , p poolWrapper , rpc * rpcclient.Client , signer user.Signer , containerID cid.ID , ownerID user. ID , attr , indexAttributeKey string , buf []byte , currentIndexFileID , indexFileSize , currentBlockHeight uint , numWorkers , maxRetries uint , debug bool ) error {
141
+ func uploadBlocksAndIndexFiles (ctx * cli.Context , p poolWrapper , rpc * rpcclient.Client , signer user.Signer , containerID cid.ID , attr , indexAttributeKey string , buf []byte , currentIndexFileID , indexFileSize , currentBlockHeight uint , numWorkers , maxRetries uint , debug bool ) error {
142
142
if currentIndexFileID * indexFileSize >= currentBlockHeight {
143
143
fmt .Fprintf (ctx .App .Writer , "No new blocks to upload. Need to upload starting from %d, current height %d\n " , currentIndexFileID * indexFileSize , currentBlockHeight )
144
144
return nil
@@ -204,7 +204,7 @@ func uploadBlocksAndIndexFiles(ctx *cli.Context, p poolWrapper, rpc *rpcclient.C
204
204
)
205
205
errRetr := retry (func () error {
206
206
var errUpload error
207
- resOid , errUpload = uploadObj (ctx .Context , p , signer , ownerID , containerID , objBytes , attrs )
207
+ resOid , errUpload = uploadObj (ctx .Context , p , signer , containerID , objBytes , attrs )
208
208
if errUpload != nil {
209
209
return errUpload
210
210
}
@@ -251,7 +251,7 @@ func uploadBlocksAndIndexFiles(ctx *cli.Context, p poolWrapper, rpc *rpcclient.C
251
251
}
252
252
err := retry (func () error {
253
253
var errUpload error
254
- _ , errUpload = uploadObj (ctx .Context , p , signer , ownerID , containerID , buf , attrs )
254
+ _ , errUpload = uploadObj (ctx .Context , p , signer , containerID , buf , attrs )
255
255
return errUpload
256
256
}, maxRetries , debug )
257
257
if err != nil {
@@ -423,16 +423,15 @@ func searchObjects(ctx context.Context, p poolWrapper, containerID cid.ID, privK
423
423
}
424
424
425
425
// uploadObj uploads object to the container using provided settings.
426
- func uploadObj (ctx context.Context , p poolWrapper , signer user.Signer , ownerID user. ID , containerID cid.ID , objData []byte , attrs []object.Attribute ) (oid.ID , error ) {
426
+ func uploadObj (ctx context.Context , p poolWrapper , signer user.Signer , containerID cid.ID , objData []byte , attrs []object.Attribute ) (oid.ID , error ) {
427
427
var (
428
428
hdr object.Object
429
429
prmObjectPutInit client.PrmObjectPutInit
430
430
resOID = oid.ID {}
431
431
)
432
432
433
- hdr .SetPayload (objData )
434
433
hdr .SetContainerID (containerID )
435
- hdr .SetOwner (ownerID )
434
+ hdr .SetOwner (signer . UserID () )
436
435
hdr .SetAttributes (attrs ... )
437
436
438
437
writer , err := p .ObjectPutInit (ctx , hdr , signer , prmObjectPutInit )
@@ -450,9 +449,6 @@ func uploadObj(ctx context.Context, p poolWrapper, signer user.Signer, ownerID u
450
449
}
451
450
res := writer .GetResult ()
452
451
resOID = res .StoredObjectID ()
453
- if resOID .IsZero () {
454
- return resOID , fmt .Errorf ("object ID is empty" )
455
- }
456
452
return resOID , nil
457
453
}
458
454
0 commit comments