Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(Local File Trigger Node): Add polling option typically good to watch network files/folders #7942

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ export class LocalFileTrigger implements INodeType {
placeholder: 'Add Option',
default: {},
options: [
{
displayName: 'Await Write Finish',
name: 'awaitWriteFinish',
type: 'boolean',
default: false,
description: 'Whether to wait until files finished writing to avoid partially read',
},
{
displayName: 'Include Linked Files/Folders',
name: 'followSymlinks',
Expand All @@ -142,7 +149,13 @@ export class LocalFileTrigger implements INodeType {
description:
'Files or paths to ignore. The whole path is tested, not just the filename. Supports <a href="https://github.com/micromatch/anymatch">Anymatch</a>- syntax.',
},

{
displayName: 'Ignore Existing Files/Folders',
name: 'ignoreInitial',
type: 'boolean',
default: true,
description: 'Whether to ignore existing files/folders to not trigger an event',
},
{
displayName: 'Max Folder Depth',
name: 'depth',
Expand Down Expand Up @@ -180,6 +193,14 @@ export class LocalFileTrigger implements INodeType {
default: -1,
description: 'How deep into the folder structure to watch for changes',
},
{
displayName: 'Use Polling',
name: 'usePolling',
type: 'boolean',
default: false,
description:
'Whether to use polling for watching. Typically necessary to successfully watch files over a network.',
},
],
},
],
Expand All @@ -200,12 +221,15 @@ export class LocalFileTrigger implements INodeType {
const watcher = watch(path, {
ignored: options.ignored === '' ? undefined : options.ignored,
persistent: true,
ignoreInitial: true,
ignoreInitial:
options.ignoreInitial === undefined ? true : (options.ignoreInitial as boolean),
followSymlinks:
options.followSymlinks === undefined ? true : (options.followSymlinks as boolean),
depth: [-1, undefined].includes(options.depth as number)
? undefined
: (options.depth as number),
usePolling: options.usePolling as boolean,
awaitWriteFinish: options.awaitWriteFinish as boolean,
});

const executeTrigger = (event: string, pathString: string) => {
Expand Down
Loading