Skip to content

Commit

Permalink
sequence search : when child process returns empty file and status 0 …
Browse files Browse the repository at this point in the history
…(OK), return empty result to client

feature.js : dnaSequenceSearch() : searchDataOut() : if ! chunk, reply OK with [].
child-process.js : childProcess() : child.on(close ) : if status OK and ! child.killed, dataOutCb(null ).
  • Loading branch information
Don-Isdale committed Jun 11, 2021
1 parent 28bec64 commit a8493d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions backend/common/models/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ module.exports = function(Feature) {

/** Receive the results from the Blast.
* @param chunk is a Buffer
* null / undefined indicates child process closed with status 0 (OK) and sent no output.
* @param cb is cbWrap of cb passed to dnaSequenceSearch().
*/
let searchDataOut = (chunk, cb) => {
if (! chunk) {
cb(null, []);
} else
if (chunk.asciiSlice(0,6) === 'Error:') {
cb(new Error(chunk.toString()));
} else {
Expand Down
9 changes: 8 additions & 1 deletion backend/common/utilities/child-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var fs = require('fs');
* @param moreParams array of params to pass as command-line params to
* child process, after [fileName, useFile]
* @param dataOutCb (Buffer chunk, cb) {}
* If child process closes with status 0 (OK) and sent no output, then
* dataOutCb will be called with chunk === null
* @param cb response node callback
* @param progressive true means pass received data back directly to
* dataOutCb, otherwise catenate it and call dataOutCb just once when
Expand Down Expand Up @@ -138,7 +140,12 @@ exports.childProcess = (scriptName, postData, useFile, fileName, moreParams, dat
const message = 'Processed file ' + fileName;
if (child.killed) {
cb(null, message, true);
} // else check again after timeout
} else { // return empty data result
dataOutCb(null, cb);
/* it would be equivalent to do : cb(null, [], true);
* dataOutCb() may have completion actions.
*/
}
}
});

Expand Down

0 comments on commit a8493d4

Please sign in to comment.