Skip to content

Commit

Permalink
Download a small chunk instead of whole
Browse files Browse the repository at this point in the history
* Should speeds things up a bit for I/O

Post OpenUserJS#1303
  • Loading branch information
Martii committed Dec 5, 2017
1 parent 951e712 commit 7fc1187
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,12 @@ exports.storeScript = function (aUser, aMeta, aBuf, aUpdate, aCallback) {
fn.get(URL.parse(icon), function (aRes) {
var chunks = [];
aRes.on('data', function (aChunk) {
var buffer = null;
chunks.push(aChunk);
buffer = Buffer.concat(chunks);
if (buffer.length > 3048) { // NOTE: KiB
aRes.destroy();
}
}).on('end', function () {
buffer = Buffer.concat(chunks);
try {
Expand Down

0 comments on commit 7fc1187

Please sign in to comment.