Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
58ef60f9
Commit
58ef60f9
authored
Jan 22, 2023
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor tweaks to file transfer.
Avoid copying data when sending, improve error handling.
parent
dbeb75ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
static/protocol.js
static/protocol.js
+16
-7
No files found.
static/protocol.js
View file @
58ef60f9
...
...
@@ -1685,7 +1685,8 @@ TransferredFile.prototype.close = function() {
}
/**
* Buffer a chunk of data received during a file transfer. Do not call this.
* Buffer a chunk of data received during a file transfer.
* Do not call this, it is called automatically when data is received.
*
* @param {Blob|ArrayBuffer} data
*/
...
...
@@ -1884,7 +1885,8 @@ TransferredFile.prototype.receive = async function() {
}
/**
* Negotiate a file transfer on the sender side. Don't call this.
* Negotiate a file transfer on the sender side.
* Don't call this, it is called automatically we receive an offer.
*
* @param {string} sdp
*/
...
...
@@ -1974,6 +1976,7 @@ TransferredFile.prototype.send = async function() {
f
.
dc
.
bufferedAmountLowThreshold
=
65536
;
/** @param {Uint8Array} a */
async
function
write
(
a
)
{
while
(
f
.
dc
.
bufferedAmount
>
f
.
dc
.
bufferedAmountLowThreshold
)
{
await
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -2012,9 +2015,7 @@ TransferredFile.prototype.send = async function() {
await
write
(
data
);
}
else
{
for
(
let
i
=
0
;
i
<
v
.
value
.
length
;
i
+=
16384
)
{
let
d
=
new
Uint8Array
(
data
.
buffer
,
i
,
Math
.
min
(
16384
,
data
.
length
-
i
),
);
let
d
=
data
.
subarray
(
i
,
Math
.
min
(
i
+
16384
,
data
.
length
));
await
write
(
d
);
}
}
...
...
@@ -2056,13 +2057,19 @@ TransferredFile.prototype.receiveData = async function(data) {
f
.
dc
.
onmessage
=
null
;
if
(
f
.
datalen
!=
f
.
size
)
{
f
.
cancel
(
'
unexpected file siz
e
'
);
f
.
cancel
(
'
extra data at end of fil
e
'
);
return
;
}
let
blob
=
f
.
getBufferedData
();
if
(
blob
.
size
!=
f
.
size
)
{
f
.
cancel
(
"
inconsistent data size (this shouldn't happen)
"
);
return
;
}
f
.
event
(
'
done
'
,
blob
);
// we've received the whole file. Send the final handshake, but don't
// complain if the peer has closed the channel in the meantime.
await
new
Promise
((
resolve
,
reject
)
=>
{
let
timer
=
setTimeout
(
function
(
e
)
{
resolve
();
},
2000
);
f
.
dc
.
onclose
=
function
(
e
)
{
...
...
@@ -2100,8 +2107,10 @@ ServerConnection.prototype.fileTransfer = function(id, username, message) {
try
{
if
(
sc
.
onfiletransfer
)
sc
.
onfiletransfer
.
call
(
sc
,
f
);
else
else
{
f
.
cancel
(
'
this client does not implement file transfer
'
);
return
;
}
}
catch
(
e
)
{
f
.
cancel
(
e
);
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment