Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit ec16fc3

Browse files
committed
Fix wrong binary encoding
Due to #1912 we were writing binaries to disk with the encoding. We need to do some additional juggling when dealing with binary data.
1 parent 7355176 commit ec16fc3

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

scripts/install.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function download(url, dest, cb) {
5151
console.log('Downloading binary from', url);
5252

5353
try {
54-
request(url, downloadOptions(), function(err, response) {
54+
request(url, downloadOptions(), function(err, response, buffer) {
5555
if (err) {
5656
reportError(err);
5757
} else if (!successful(response)) {
@@ -60,10 +60,12 @@ function download(url, dest, cb) {
6060
console.log('Download complete');
6161

6262
if (successful(response)) {
63-
response.pipe(fs.createWriteStream(dest));
63+
fs.createWriteStream(dest)
64+
.on('error', cb)
65+
.end(buffer, cb);
66+
} else {
67+
cb();
6468
}
65-
66-
cb();
6769
}
6870
})
6971
.on('response', function(response) {

scripts/util/downloadoptions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ module.exports = function() {
1818
timeout: 60000,
1919
headers: {
2020
'User-Agent': userAgent(),
21-
}
21+
},
22+
encoding: null,
2223
};
2324

2425
var proxyConfig = proxy();

0 commit comments

Comments
 (0)