Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
f5d87011
Commit
f5d87011
authored
Nov 1, 2022
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix progress callback error reporting
parent
0ec3de42
No related branches found
No related tags found
1 merge request
!430
XX-4277 / Fix file transfer crashes
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/fileTransfer.go
+20
-7
20 additions, 7 deletions
bindings/fileTransfer.go
bindings/fileTransfer_test.go
+5
-0
5 additions, 0 deletions
bindings/fileTransfer_test.go
with
25 additions
and
7 deletions
bindings/fileTransfer.go
+
20
−
7
View file @
f5d87011
...
@@ -203,6 +203,7 @@ func (f *FileTransfer) Send(payload, recipientID []byte, retry float32,
...
@@ -203,6 +203,7 @@ func (f *FileTransfer) Send(payload, recipientID []byte, retry float32,
base64
.
StdEncoding
.
EncodeToString
(
recipientID
))
base64
.
StdEncoding
.
EncodeToString
(
recipientID
))
// Unmarshal recipient ID
// Unmarshal recipient ID
jww
.
INFO
.
Printf
(
"** FileTransfer.Send before id.Unmarshal"
)
recipient
,
err
:=
id
.
Unmarshal
(
recipientID
)
recipient
,
err
:=
id
.
Unmarshal
(
recipientID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -219,7 +220,11 @@ func (f *FileTransfer) Send(payload, recipientID []byte, retry float32,
...
@@ -219,7 +220,11 @@ func (f *FileTransfer) Send(payload, recipientID []byte, retry float32,
Transmitted
:
int
(
arrived
),
Transmitted
:
int
(
arrived
),
Total
:
int
(
total
),
Total
:
int
(
total
),
}
}
pm
,
err
:=
json
.
Marshal
(
progress
)
pm
,
err2
:=
json
.
Marshal
(
progress
)
if
err2
!=
nil
{
jww
.
FATAL
.
Panicf
(
"[FT] Failed to JSON marshal sent Progress object: %+v"
,
err
)
}
callback
.
Callback
(
pm
,
&
FilePartTracker
{
t
},
err
)
callback
.
Callback
(
pm
,
&
FilePartTracker
{
t
},
err
)
}
}
...
@@ -295,7 +300,11 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
...
@@ -295,7 +300,11 @@ func (f *FileTransfer) RegisterSentProgressCallback(tidBytes []byte,
Transmitted
:
int
(
arrived
),
Transmitted
:
int
(
arrived
),
Total
:
int
(
total
),
Total
:
int
(
total
),
}
}
pm
,
err
:=
json
.
Marshal
(
progress
)
pm
,
err2
:=
json
.
Marshal
(
progress
)
if
err2
!=
nil
{
jww
.
FATAL
.
Panicf
(
"[FT] Failed to JSON marshal sent Progress object: %+v"
,
err
)
}
callback
.
Callback
(
pm
,
&
FilePartTracker
{
t
},
err
)
callback
.
Callback
(
pm
,
&
FilePartTracker
{
t
},
err
)
}
}
p
:=
time
.
Millisecond
*
time
.
Duration
(
period
)
p
:=
time
.
Millisecond
*
time
.
Duration
(
period
)
...
@@ -325,7 +334,11 @@ func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte,
...
@@ -325,7 +334,11 @@ func (f *FileTransfer) RegisterReceivedProgressCallback(tidBytes []byte,
Transmitted
:
int
(
received
),
Transmitted
:
int
(
received
),
Total
:
int
(
total
),
Total
:
int
(
total
),
}
}
pm
,
err
:=
json
.
Marshal
(
progress
)
pm
,
err2
:=
json
.
Marshal
(
progress
)
if
err2
!=
nil
{
jww
.
FATAL
.
Panicf
(
"[FT] Failed to JSON marshal received Progress object: %+v"
,
err
)
}
callback
.
Callback
(
pm
,
&
FilePartTracker
{
t
},
err
)
callback
.
Callback
(
pm
,
&
FilePartTracker
{
t
},
err
)
}
}
p
:=
time
.
Millisecond
*
time
.
Duration
(
period
)
p
:=
time
.
Millisecond
*
time
.
Duration
(
period
)
...
...
This diff is collapsed.
Click to expand it.
bindings/fileTransfer_test.go
+
5
−
0
View file @
f5d87011
...
@@ -17,7 +17,9 @@ import (
...
@@ -17,7 +17,9 @@ import (
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
)
)
// Creates example JSON outputs used in documentation.
func
TestFileTransfer_inputs
(
t
*
testing
.
T
)
{
func
TestFileTransfer_inputs
(
t
*
testing
.
T
)
{
// FileSend
fs
:=
&
FileSend
{
fs
:=
&
FileSend
{
Name
:
"testfile.txt"
,
Name
:
"testfile.txt"
,
Type
:
"text file"
,
Type
:
"text file"
,
...
@@ -28,6 +30,7 @@ func TestFileTransfer_inputs(t *testing.T) {
...
@@ -28,6 +30,7 @@ func TestFileTransfer_inputs(t *testing.T) {
t
.
Log
(
"FileSend example JSON:"
)
t
.
Log
(
"FileSend example JSON:"
)
fmt
.
Printf
(
"%s
\n\n
"
,
fsm
)
fmt
.
Printf
(
"%s
\n\n
"
,
fsm
)
// ReceivedFile
tid
,
_
:=
fileTransfer
.
NewTransferID
(
csprng
.
NewSystemRNG
())
tid
,
_
:=
fileTransfer
.
NewTransferID
(
csprng
.
NewSystemRNG
())
sid
,
_
:=
id
.
NewRandomID
(
csprng
.
NewSystemRNG
(),
id
.
User
)
sid
,
_
:=
id
.
NewRandomID
(
csprng
.
NewSystemRNG
(),
id
.
User
)
rf
:=
&
ReceivedFile
{
rf
:=
&
ReceivedFile
{
...
@@ -42,6 +45,7 @@ func TestFileTransfer_inputs(t *testing.T) {
...
@@ -42,6 +45,7 @@ func TestFileTransfer_inputs(t *testing.T) {
t
.
Log
(
"ReceivedFile example JSON:"
)
t
.
Log
(
"ReceivedFile example JSON:"
)
fmt
.
Printf
(
"%s
\n\n
"
,
rfm
)
fmt
.
Printf
(
"%s
\n\n
"
,
rfm
)
// Progress
p
:=
&
Progress
{
p
:=
&
Progress
{
TransferID
:
&
tid
,
TransferID
:
&
tid
,
Completed
:
false
,
Completed
:
false
,
...
@@ -52,6 +56,7 @@ func TestFileTransfer_inputs(t *testing.T) {
...
@@ -52,6 +56,7 @@ func TestFileTransfer_inputs(t *testing.T) {
t
.
Log
(
"Progress example JSON:"
)
t
.
Log
(
"Progress example JSON:"
)
fmt
.
Printf
(
"%s
\n\n
"
,
pm
)
fmt
.
Printf
(
"%s
\n\n
"
,
pm
)
// EventReport
er
:=
&
EventReport
{
er
:=
&
EventReport
{
Priority
:
1
,
Priority
:
1
,
Category
:
"Test Events"
,
Category
:
"Test Events"
,
...
...
This diff is collapsed.
Click to expand it.
Dariusz Rybicki
@darrarski.xx
mentioned in commit
elixxir-dapps-sdk-swift@503cd809
·
Nov 1, 2022
mentioned in commit
elixxir-dapps-sdk-swift@503cd809
mentioned in commit elixxir-dapps-sdk-swift@503cd809d96b6c6c8f4132be65f898b527a3c929
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment