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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
0bb6a0f5
Commit
0bb6a0f5
authored
3 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Make FileTransfer in bindings a pointer
parent
c062a271
No related branches found
No related tags found
1 merge request
!117
Release
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/fileTransfer.go
+15
-15
15 additions, 15 deletions
bindings/fileTransfer.go
with
15 additions
and
15 deletions
bindings/fileTransfer.go
+
15
−
15
View file @
0bb6a0f5
...
...
@@ -48,7 +48,7 @@ type FileTransferReceiveFunc interface {
// fileTransfer.Params object. If it is left empty, then defaults are used. It
// must match the following format: {"MaxThroughput":150000}
func
NewFileTransferManager
(
client
*
Client
,
receiveFunc
FileTransferReceiveFunc
,
parameters
string
)
(
FileTransfer
,
error
)
{
parameters
string
)
(
*
FileTransfer
,
error
)
{
receiveCB
:=
func
(
tid
ftCrypto
.
TransferID
,
fileName
,
fileType
string
,
sender
*
id
.
ID
,
size
uint32
,
preview
[]
byte
)
{
...
...
@@ -61,23 +61,23 @@ func NewFileTransferManager(client *Client, receiveFunc FileTransferReceiveFunc,
if
parameters
!=
""
{
err
:=
json
.
Unmarshal
([]
byte
(
parameters
),
&
p
)
if
err
!=
nil
{
return
F
il
eTransfer
{}
,
err
return
n
il
,
err
}
}
// Create new file transfer manager
m
,
err
:=
ft
.
NewManager
(
&
client
.
api
,
receiveCB
,
p
)
if
err
!=
nil
{
return
F
il
eTransfer
{}
,
err
return
n
il
,
err
}
// Start sending and receiving threads
err
=
client
.
api
.
AddService
(
m
.
StartProcesses
)
if
err
!=
nil
{
return
F
il
eTransfer
{}
,
err
return
n
il
,
err
}
return
FileTransfer
{
m
},
nil
return
&
FileTransfer
{
m
},
nil
}
// Send sends a file to the recipient. The sender must have an E2E relationship
...
...
@@ -95,7 +95,7 @@ func NewFileTransferManager(client *Client, receiveFunc FileTransferReceiveFunc,
// Returns a unique transfer ID used to identify the transfer.
// PeriodMS is the duration, in milliseconds, to wait between progress callback
// calls. Set this large enough to prevent spamming.
func
(
f
FileTransfer
)
Send
(
fileName
,
fileType
string
,
fileData
[]
byte
,
func
(
f
*
FileTransfer
)
Send
(
fileName
,
fileType
string
,
fileData
[]
byte
,
recipientID
[]
byte
,
retry
float32
,
preview
[]
byte
,
progressFunc
FileTransferSentProgressFunc
,
periodMS
int
)
([]
byte
,
error
)
{
...
...
@@ -134,7 +134,7 @@ func (f FileTransfer) Send(fileName, fileType string, fileData []byte,
// not be reported and instead, the progress will be reported once at the end of
// the period.
// The period is specified in milliseconds.
func
(
f
FileTransfer
)
RegisterSendProgressCallback
(
transferID
[]
byte
,
func
(
f
*
FileTransfer
)
RegisterSendProgressCallback
(
transferID
[]
byte
,
progressFunc
FileTransferSentProgressFunc
,
periodMS
int
)
error
{
// Unmarshal transfer ID
...
...
@@ -154,7 +154,7 @@ func (f FileTransfer) RegisterSendProgressCallback(transferID []byte,
// Resend resends a file if sending fails. This function should only be called
//if the interfaces.SentProgressCallback returns an error.
func
(
f
FileTransfer
)
Resend
(
transferID
[]
byte
)
error
{
func
(
f
*
FileTransfer
)
Resend
(
transferID
[]
byte
)
error
{
// Unmarshal transfer ID
tid
:=
ftCrypto
.
UnmarshalTransferID
(
transferID
)
...
...
@@ -164,7 +164,7 @@ func (f FileTransfer) Resend(transferID []byte) error {
// CloseSend deletes a sent file transfer from the sent transfer map and from
// storage once a transfer has completed or reached the retry limit. Returns an
// error if the transfer has not run out of retries.
func
(
f
FileTransfer
)
CloseSend
(
transferID
[]
byte
)
error
{
func
(
f
*
FileTransfer
)
CloseSend
(
transferID
[]
byte
)
error
{
// Unmarshal transfer ID
tid
:=
ftCrypto
.
UnmarshalTransferID
(
transferID
)
...
...
@@ -181,7 +181,7 @@ func (f FileTransfer) CloseSend(transferID []byte) error {
// Once the callback reports that the transfer has completed, the recipient
// can get the full file by calling Receive.
// The period is specified in milliseconds.
func
(
f
FileTransfer
)
RegisterReceiveProgressCallback
(
transferID
[]
byte
,
func
(
f
*
FileTransfer
)
RegisterReceiveProgressCallback
(
transferID
[]
byte
,
progressFunc
FileTransferReceivedProgressFunc
,
periodMS
int
)
error
{
// Unmarshal transfer ID
tid
:=
ftCrypto
.
UnmarshalTransferID
(
transferID
)
...
...
@@ -202,7 +202,7 @@ func (f FileTransfer) RegisterReceiveProgressCallback(transferID []byte,
// It deletes the transfer from the received transfer map and from storage.
// Returns an error if the transfer is not complete, the full file cannot be
// verified, or if the transfer cannot be found.
func
(
f
FileTransfer
)
Receive
(
transferID
[]
byte
)
([]
byte
,
error
)
{
func
(
f
*
FileTransfer
)
Receive
(
transferID
[]
byte
)
([]
byte
,
error
)
{
// Unmarshal transfer ID
tid
:=
ftCrypto
.
UnmarshalTransferID
(
transferID
)
...
...
@@ -214,24 +214,24 @@ func (f FileTransfer) Receive(transferID []byte) ([]byte, error) {
////////////////////////////////////////////////////////////////////////////////
// GetMaxFilePreviewSize returns the maximum file preview size, in bytes.
func
(
f
FileTransfer
)
GetMaxFilePreviewSize
()
int
{
func
(
f
*
FileTransfer
)
GetMaxFilePreviewSize
()
int
{
return
ft
.
PreviewMaxSize
}
// GetMaxFileNameByteLength returns the maximum length, in bytes, allowed for a
// file name.
func
(
f
FileTransfer
)
GetMaxFileNameByteLength
()
int
{
func
(
f
*
FileTransfer
)
GetMaxFileNameByteLength
()
int
{
return
ft
.
FileNameMaxLen
}
// GetMaxFileTypeByteLength returns the maximum length, in bytes, allowed for a
// file type.
func
(
f
FileTransfer
)
GetMaxFileTypeByteLength
()
int
{
func
(
f
*
FileTransfer
)
GetMaxFileTypeByteLength
()
int
{
return
ft
.
FileTypeMaxLen
}
// GetMaxFileSize returns the maximum file size, in bytes, allowed to be
// transferred.
func
(
f
FileTransfer
)
GetMaxFileSize
()
int
{
func
(
f
*
FileTransfer
)
GetMaxFileSize
()
int
{
return
ft
.
FileMaxSize
}
This diff is collapsed.
Click to expand it.
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