Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Marsaud Smb2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
nanahira
Marsaud Smb2
Commits
c26cd908
Commit
c26cd908
authored
Jul 11, 2018
by
Julien Fontanet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(createReadStream): various issues
parent
83edb5d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
21 deletions
+14
-21
lib/api/createReadStream.js
lib/api/createReadStream.js
+14
-21
No files found.
lib/api/createReadStream.js
View file @
c26cd908
...
...
@@ -21,15 +21,11 @@ module.exports = function createReadStream(path, options, cb) {
return
cb
(
err
);
}
var
offset
=
new
BigInt
(
file
.
EndofFile
.
length
,
options
.
start
||
0
)
;
var
fileSize
=
BigInt
.
fromBuffer
(
file
.
EndofFile
);
var
offset
=
options
.
start
||
0
;
var
end
=
BigInt
.
fromBuffer
(
file
.
EndofFile
).
toNumber
(
);
var
end
=
options
.
end
;
if
(
end
!=
null
)
{
end
=
new
BigInt
(
8
,
end
+
1
);
if
(
end
.
gt
(
fileSize
))
{
fileSize
=
end
;
}
if
(
options
.
end
<
end
)
{
end
=
options
.
end
+
1
;
// end option is inclusive
}
var
close
=
request
.
bind
(
undefined
,
'
close
'
,
file
,
connection
);
...
...
@@ -49,9 +45,9 @@ module.exports = function createReadStream(path, options, cb) {
return
;
}
if
(
offset
.
ge
(
fileSize
)
)
{
if
(
offset
>=
end
)
{
return
close
(
function
()
{
this
.
push
(
null
);
stream
.
push
(
null
);
});
}
...
...
@@ -60,21 +56,18 @@ module.exports = function createReadStream(path, options, cb) {
'
read
'
,
{
FileId
:
file
.
FileId
,
Length
:
Math
.
min
(
maxPacketSize
,
size
),
Offset
:
offset
.
toBuffer
(),
Length
:
Math
.
min
(
maxPacketSize
,
size
,
end
-
offset
),
Offset
:
new
BigInt
(
8
,
offset
)
.
toBuffer
(),
},
connection
,
function
(
err
,
content
)
{
try
{
if
(
err
!=
null
)
{
return
process
.
nextTick
(
stream
.
emit
.
bind
(
stream
,
'
error
'
,
err
));
}
offset
=
offset
.
add
(
content
.
length
);
stream
.
push
(
content
);
}
finally
{
running
=
false
;
running
=
false
;
if
(
err
!=
null
)
{
return
process
.
nextTick
(
stream
.
emit
.
bind
(
stream
,
'
error
'
,
err
));
}
offset
+=
content
.
length
;
stream
.
push
(
content
);
}
);
};
...
...
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