Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 765b1d5

Browse files
salciolukaszsalamondanecreekphotography
authored
Issue412 (#413)
* support for glob paths * support for globs in trigger patterns * Added changeLog entry * reverted gitignore * update package-lock.json * package-lock update * reverted gitignore * reverted gitignore * Apply suggestions from code review Co-authored-by: danecreekphotography <info@danecreekphotography.com> * Removed build wornings. * renamed sample dog folder Co-authored-by: lukaszsalamon <lukasz@luziklimited.com> Co-authored-by: danecreekphotography <info@danecreekphotography.com>
1 parent b8761a0 commit 765b1d5

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

.devcontainer/triggers.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
{
2626
"name": "Dog detector",
27-
"watchPattern": "/aiinput/Dog*.jpg",
27+
"watchPattern": "/aiinput/**/Dog*.jpg",
2828
"enabled": true,
2929
"threshold": {
3030
"minimum": 50,

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Add support for `customEndpoint` on a trigger to support custom Deepstack models. Resolves [issue 416](https://github.com/danecreekphotography/node-deepstackai-trigger/issues/416).
6+
- Support for glob patterns in trigger watchPatterns. Resolves [issue 412](https://github.com/danecreekphotography/node-deepstackai-trigger/issues/412).
67

78
## 5.6.1
89

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"devDependencies": {
5858
"@types/ajv-keywords": "^3.4.0",
5959
"@types/express": "^4.17.6",
60+
"@types/glob": "^7.1.3",
6061
"@types/http-terminator": "^2.0.1",
6162
"@types/jest": "^25.2.3",
6263
"@types/mkdirp": "^1.0.1",
127 KB
Loading

sampleConfiguration/triggers.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
{
2626
"name": "Dog detector",
27-
"watchPattern": "/aiinput/Dog*.jpg",
27+
"watchPattern": "/aiinput/**/Dog*.jpg",
2828
"enabled": true,
2929
"threshold": {
3030
"minimum": 50,

src/TriggerManager.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import * as log from "./Log";
77
import * as MQTTManager from "./handlers/mqttManager/MqttManager";
88

99
import ITriggerConfigJson from "./types/ITriggerConfigJson";
10-
import * as fs from "fs";
10+
import glob from "glob"
1111
import MqttHandlerConfig from "./handlers/mqttManager/MqttHandlerConfig";
12-
import path from "path";
1312
import PushbulletConfig from "./handlers/pushbulletManager/PushbulletConfig";
1413
import PushoverConfig from "./handlers/pushoverManager/PushoverConfig";
1514
import Rect from "./Rect";
@@ -69,7 +68,7 @@ export function loadConfiguration(configurations: IConfiguration[]): IConfigurat
6968
if (!triggerConfigJson) {
7069
throw Error(
7170
"Unable to find a trigger configuration file. Verify the trigger secret points to a file " +
72-
"called triggers.json or that the /config mount point contains a file called triggers.json.",
71+
"called triggers.json or that the /config mount point contains a file called triggers.json.",
7372
);
7473
}
7574

@@ -272,21 +271,19 @@ export function resetOverallStatistics(): ITriggerStatistics {
272271
*/
273272
export function verifyTriggerWatchLocations(): boolean {
274273
const invalidWatchLocations = triggers?.filter(trigger => {
275-
const watchFolder = path.dirname(trigger.watchPattern);
276-
277274
let files: string[];
278275

279276
try {
280-
files = fs.readdirSync(watchFolder);
277+
files = glob.sync(trigger.watchPattern);
281278
} catch (e) {
282279
log.warn(
283280
"Trigger manager",
284-
`Unable to read contents of watch folder ${watchFolder} for trigger ${trigger.name}. Check and make sure the image folder is mounted properly. ${e}`,
281+
`Unable to read contents of watch folder ${trigger.watchPattern} for trigger ${trigger.name}. Check and make sure the image folder is mounted properly. ${e}`,
285282
);
286283
return true;
287284
}
288285

289-
log.verbose("Trigger manager", `There are ${files.length} images waiting in ${watchFolder} for ${trigger.name}.`);
286+
log.verbose("Trigger manager", `There are ${files.length} images waiting in ${trigger.watchPattern} for ${trigger.name}.`);
290287
return false;
291288
});
292289

0 commit comments

Comments
 (0)