OpenVeo Publish server

API Docs for: 8.0.0
Show:

DirectoryWatcher

Summary

Defines a directory watcher to watch for changes inside a directory and its sub directories.

Constructor

DirectoryWatcher

Syntax

DirectoryWatcher

(
  • directoryPath
  • [options]
)

Summary

Parameters:

  • directoryPath Array

    The absolute path of the directory to watch

  • [options] Object optional

    Watcher options

    • [stabilityThreshold] Number optional

      Number of milliseconds to wait before considering a file as stable

Methods

close

Syntax

close

(
  • [directoryPath]
)

Summary

Stops watching the directory and all its sub directories.

Parameters:

  • [directoryPath] String optional

    Absolute path of the directory to stop watching. If not specified the directory and all its sub directories won't be watched anymore

createWatcher

Syntax

createWatcher

(
  • directoryPath
  • callback
)
private async

Summary

Creates a watcher on the given directory.

Parameters:

  • directoryPath String

    The absolute path of the directory to watch

  • callback Function

    The function to call when its done

    • Error An error if something went wrong

isWatched

Syntax

isWatched

(
  • directoryPath
)
Boolean private

Summary

Checks if a sub directory is actually being watched.

Parameters:

  • directoryPath String

    The absolute path of the directory to check

Returns:

Boolean:

true if directory is actually being watched, false otherwise

watch

Syntax

watch

(
  • callback
)
async

Summary

Watches a directory and all its sub directories.

Parameters:

  • callback Function

    The function to call when its done

    • Error An error if something went wrong

Properties

directoryPath

Syntax

directoryPath

String final

Summary

The absolute path of the watched directory.

fsWatchers

Syntax

fsWatchers

Array final

Summary

List of watchers for this directory and its sub directories.

options

Syntax

options

Object final

Summary

Watcher options.

Events

create

Syntax

create

Summary

Fired when a new resource (file or directory) has been added to the watched folder.

Event Payload:

  • Path String

    of the added resource

delete

Syntax

delete

Summary

Fired when a resource (file or directory) has been deleted from the watched folder.

Event Payload:

  • Path String

    of the resource before it has been removed

error

Syntax

error

Summary

Fired when an error occurred.

Event Payload:

watch

Syntax

watch

Summary

Fired when a directory is added to the watched directory.

Fired after "create" event in case the directory is added to the watched directory.

Event Payload:

  • Path String

    of the directory