Options
All
  • Public
  • Public/Protected
  • All
Menu

Because URIs can be watched by different clients, we'll track how many are listening for a given URI.

This component wraps the whole start/stop process given some reference count.

Once there are no more references the handle will wait for some time before destroying its resources.

Hierarchy

  • NsfwWatcher

Index

Constructors

constructor

Properties

Protected debugId

debugId: number = ...

Used for debugging to keep track of the watchers.

Protected Readonly deferredDisposalDeferred

deferredDisposalDeferred: Deferred<never> = ...

This deferred only rejects with WatcherDisposal and never resolves.

Protected Readonly deferredDisposalTimeout

deferredDisposalTimeout: number = 10_000

Protected deferredDisposalTimer

deferredDisposalTimer: undefined | Timer

When the ref count hits zero, we schedule this watch handle to be disposed.

Protected disposed

disposed: boolean = false

Protected Readonly fileSystemWatcherClient

fileSystemWatcherClient: FileSystemWatcherServiceClient

Readonly fsPath

fsPath: string

Protected nsfw

nsfw: undefined | NSFW

When this field is set, it means the nsfw instance was successfully started.

Protected nsfwEventProcessingQueue

nsfwEventProcessingQueue: Promise<void> = ...

Ensures that events are processed in the order they are emitted, despite being processed async.

Protected Readonly nsfwFileSystemWatchServerOptions

nsfwFileSystemWatchServerOptions: NsfwFileSystemWatcherServerOptions

Protected Readonly refsPerClient

refsPerClient: Map<number, { value: number }> = ...

We count each reference made to this watcher, per client.

We do this to know where to send events via the network.

An entry should be removed when its value hits zero.

Readonly watcherOptions

watcherOptions: NsfwWatcherOptions

Readonly whenDisposed

whenDisposed: Promise<void> = ...

Resolves once this handle disposed itself and its resources. Never throws.

Readonly whenStarted

whenStarted: Promise<boolean>

Promise that resolves when the watcher is fully started, or got disposed.

Will reject if an error occurred while starting.

returns

true if successfully started, false if disposed early.

Static Protected debugIdSequence

debugIdSequence: number = 0

Methods

Protected _dispose

  • _dispose(): Promise<void>

addRef

  • addRef(clientId: number): void

Protected createNsfw

  • createNsfw(): Promise<NSFW>

Protected debug

  • debug(prefix: string, ...params: any[]): void

Protected fireError

  • fireError(): void

getClientIds

  • getClientIds(): number[]

getTotalReferences

  • getTotalReferences(): number

Protected handleNsfwEvents

  • handleNsfwEvents(events: FileChangeEvent[]): void

Protected info

  • info(prefix: string, ...params: any[]): void

Protected isIgnored

  • isIgnored(path: string): boolean

isInUse

  • isInUse(): boolean

Protected onRefsReachZero

  • onRefsReachZero(): void

Protected onRefsRevive

  • onRefsRevive(): void

Protected orCancel

  • orCancel<T>(promise: Promise<T>): Promise<T>

Protected pushFileChange

removeRef

  • removeRef(clientId: number): void

Protected resolveEventPath

  • resolveEventPath(directory: string, file: string): Promise<string>

Protected start

  • start(): Promise<void>

Protected stopNsfw

  • stopNsfw(watcher: NSFW): Promise<void>