Skip to content

Commit

Permalink
fix: pass upcoming filename to start function to use in response
Browse files Browse the repository at this point in the history
  • Loading branch information
jakowenko committed Sep 3, 2021
1 parent d3e0098 commit 32f0bae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion api/src/controllers/match.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ module.exports.reprocess = async (req, res) => {
throw HTTPError(BAD_REQUEST, 'No match found');
}

const results = await process.start(`${STORAGE.PATH}/matches/${match.filename}`);
const results = await process.start(
match.filename,
`${STORAGE.PATH}/matches/${match.filename}`
);
database.update.match({
id: match.id,
event: JSON.parse(match.event),
Expand Down
6 changes: 3 additions & 3 deletions api/src/util/process.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports.polling = async (event, { retries, id, type, url, breakMatch, MAT
filesystem.writer(tmp.mask, buffer);
}

const results = await this.start(tmp.mask || tmp.source, attempts);
const results = await this.start(filename, tmp.mask || tmp.source, attempts);

const foundMatch = !!results.flatMap((obj) => obj.results.filter((item) => item.match))
.length;
Expand Down Expand Up @@ -89,10 +89,10 @@ module.exports.save = async (event, results, filename, tmp) => {
}
};

module.exports.start = async (filename, attempts = 1) => {
module.exports.start = async (filename, tmp, attempts = 1) => {
const promises = [];
for (const detector of DETECTORS) {
promises.push(this.process({ detector, tmp: filename }));
promises.push(this.process({ detector, tmp }));
}
let results = await Promise.all(promises);

Expand Down

0 comments on commit 32f0bae

Please sign in to comment.