kopia lustrzana https://github.com/c9/core
fix error handling in standalone
rodzic
85d179ea43
commit
cfa07f4449
|
@ -168,6 +168,8 @@ function plugin(options, imports, register) {
|
||||||
});
|
});
|
||||||
var path = resolve(__dirname + "/../../build/output/latest.tar.gz");
|
var path = resolve(__dirname + "/../../build/output/latest.tar.gz");
|
||||||
fs.readlink(path, function(err, target) {
|
fs.readlink(path, function(err, target) {
|
||||||
|
if (err) return next(err);
|
||||||
|
|
||||||
res.end((target || "").split(".")[0]);
|
res.end((target || "").split(".")[0]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -176,9 +178,19 @@ function plugin(options, imports, register) {
|
||||||
var filename = req.params.path;
|
var filename = req.params.path;
|
||||||
var path = resolve(__dirname + "/../../build/output/" + filename);
|
var path = resolve(__dirname + "/../../build/output/" + filename);
|
||||||
|
|
||||||
res.writeHead(200, {"Content-Type": "application/octet-stream"});
|
|
||||||
var stream = fs.createReadStream(path);
|
var stream = fs.createReadStream(path);
|
||||||
stream.pipe(res);
|
stream.on("error", function(err) {
|
||||||
|
next(err);
|
||||||
|
});
|
||||||
|
stream.on("data", function(data) {
|
||||||
|
if (!res.headersSent)
|
||||||
|
res.writeHead(200, {"Content-Type": "application/octet-stream"});
|
||||||
|
|
||||||
|
res.write(data);
|
||||||
|
});
|
||||||
|
stream.on("end", function(data) {
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
api.get("/configs/require_config.js", function(req, res, next) {
|
api.get("/configs/require_config.js", function(req, res, next) {
|
||||||
|
|
Ładowanie…
Reference in New Issue