mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Allow specifying polling delay on dirWatch
This commit is contained in:
parent
fff40747d2
commit
d4f25eee3c
|
|
@ -6,6 +6,7 @@
|
|||
- Fix potential error in handling keypadBeeps styles.
|
||||
- Change handling of skip delay on client.
|
||||
- Fix beep method not completing promise in some situation.
|
||||
- Allow specifying polling delay on dirWatch
|
||||
|
||||
# Version 4.6
|
||||
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ dirWatch: {
|
|||
system?: number | string; // optional
|
||||
talkgroup?: number | string; // optional
|
||||
type?: "default" | "trunk-recorder"; // optional, default is default
|
||||
usePolling?: boolean; // optional, default is false
|
||||
usePolling?: boolean | number; // optional, value is in ms, true = 1000ms, default is false
|
||||
}[]
|
||||
```
|
||||
|
||||
|
|
@ -356,6 +356,7 @@ dirWatch: {
|
|||
* **system** - A valid system id defined in **rdioScanner.systems**.
|
||||
* **talkgroup** - A valid talkgroup id defined in **rdioScanner.systems**.
|
||||
* **type** - In case of *Trunk Recorder*, the metadata of the *JSON file* will be used.
|
||||
* **usePolling** - When monitoring a network folder, you must use Polling for dirWatch to work. However, this is very CPU intensive and should be used with care. You can also try values greater than 1000 to decrease CPU consumption.
|
||||
|
||||
> Note that [Rdio Scanner](https://github.com/chuot/rdio-scanner) must know the **system id** and the **talkgroup id** for the call to be ingested. These two values must be specified either by **dirWatch.system**, **dirWatch.talkgroup**, **dirWatch.mask** or a mix of them. **dirWatch.system** and **dirWatch.talkgroup** have priority over **dirWatch.mask**.
|
||||
|
||||
|
|
@ -382,7 +383,7 @@ Default value is an empty array `[]` .
|
|||
"extension": "wav",
|
||||
"system": 21,
|
||||
"type": "trunk-recorder"
|
||||
},
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class DirWatch {
|
|||
|
||||
this.registredDirectories = [];
|
||||
|
||||
ctx.once('ready', () => {
|
||||
this.config.forEach((dirWatch = {}) => {
|
||||
if (typeof dirWatch.directory !== 'string' || !dirWatch.directory.length) {
|
||||
console.error(`Config: No dirWatch.direction defined`);
|
||||
|
|
@ -66,7 +65,11 @@ class DirWatch {
|
|||
delete dirWatch.mask;
|
||||
}
|
||||
|
||||
if (typeof dirWatch.usePolling !== 'boolean' || !dirWatch.usePolling) {
|
||||
dirWatch.usePolling = dirWatch.usePolling === true ? true
|
||||
: typeof dirWatch.usePolling === 'number' && dirWatch.usePolling >= 1000 ? dirWatch.usePolling
|
||||
: false;
|
||||
|
||||
if (!dirWatch.usePolling) {
|
||||
delete dirWatch.usePolling;
|
||||
}
|
||||
|
||||
|
|
@ -92,13 +95,22 @@ class DirWatch {
|
|||
} else {
|
||||
this.registredDirectories.push(dir);
|
||||
}
|
||||
});
|
||||
|
||||
const watcher = chokidar.watch(dir, {
|
||||
ctx.once('ready', () => {
|
||||
this.config.forEach((dirWatch = {}) => {
|
||||
const options = {
|
||||
awaitWriteFinish: true,
|
||||
ignoreInitial: !dirWatch.deleteAfter,
|
||||
recursive: true,
|
||||
usePolling: dirWatch.usePolling,
|
||||
});
|
||||
usePolling: !!dirWatch.usePolling || false,
|
||||
};
|
||||
|
||||
if (options.usePolling) {
|
||||
options.binaryInterval = options.interval = dirWatch.usePolling === true ? 1000 : dirWatch.usePolling;
|
||||
}
|
||||
|
||||
const watcher = chokidar.watch(path.resolve(__dirname, '../../..', dirWatch.directory), options);
|
||||
|
||||
switch (dirWatch.type) {
|
||||
case 'trunk-recorder':
|
||||
|
|
|
|||
Loading…
Reference in a new issue