Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add try/catch around grep per matt's suggestion for future kill work

  • Loading branch information...
commit ed5bb7b100330552c767cf79ece26411334a061a 1 parent 282fc00
Garen Torikian authored
Showing with 15 additions and 8 deletions.
  1. +15 −8 lib/DAV/plugins/codesearch.js
View
23 lib/DAV/plugins/codesearch.js
@@ -135,7 +135,7 @@ var prevFile;
prevFile = null;
var uri = this.handler.getRequestUri();
- var options = this.parseOptions(dom);
+ var options = this.parseOptions(dom);
var self = this;
options.uri = uri;
this.handler.server.tree.getNodeForPath(uri, function(err, node) {
@@ -223,14 +223,21 @@ var prevFile;
if (jsDAV.debugMode) {
Util.log("search command: " + cmd);
}
-
- var grep = Spawn("/bin/bash", ["-c", cmd]), err = "", out = "";
- grep.stdout.setEncoding("utf8");
- grep.stderr.setEncoding("utf8");
+ try {
+ this.grep = Spawn("/bin/bash", ["-c", cmd]);
+ }
+ catch (e) {
+ return cbend(null, "Could not spawn grep process");
+ }
+
+ var err = "", out = "";
+
+ this.grep.stdout.setEncoding("utf8");
+ this.grep.stderr.setEncoding("utf8");
var buffer = '';
- grep.stdout.on("data", function(data) {
+ this.grep.stdout.on("data", function(data) {
if (!Util.empty(data)) {
buffer += data;
if(data.indexOf("\n") !== -1) {
@@ -239,7 +246,7 @@ var prevFile;
}
}
});
- grep.stderr.on("data", function(data) {
+ this.grep.stderr.on("data", function(data) {
if (!Util.empty(data)) {
buffer += data;
if(data.indexOf("\n") !== -1) {
@@ -248,7 +255,7 @@ var prevFile;
}
}
});
- grep.on("exit", function(code, signal) {
+ this.grep.on("exit", function(code, signal) {
cbend(null, '\nResults: {"count": '+ count + ', "filecount":' + filecount + '}');
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.