mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-05-19 14:01:21 +00:00
cli: implement local→CouchDB file watching via chokidar
- Add chokidar ^4.0.0 as dependency (root package.json, runtime-package.json) - Mark chokidar as external in vite.config.ts (not bundled, loaded at runtime) - Implement CLIWatchAdapter.beginWatch() with chokidar: - ignoreInitial: true (startup files handled by mirror scan) - awaitWriteFinish to prevent partial-write events - Excludes dotfiles and .livesync/ directory at watcher level - Maps add/change/unlink/addDir/unlinkDir to IStorageEventWatchHandlers - Fatal error handler: logs clearly and releases watcher resources - Add close() to CLIWatchAdapter, StorageEventManagerCLI for clean shutdown - Register onUnload hook in CLIServiceModules to close watcher on shutdown
This commit is contained in:
@@ -10,9 +10,10 @@ export class StorageEventManagerCLI extends StorageEventManagerBase<CLIStorageEv
|
||||
constructor(
|
||||
basePath: string,
|
||||
core: LiveSyncBaseCore<ServiceContext, IMinimumLiveSyncCommands>,
|
||||
dependencies: StorageEventManagerBaseDependencies
|
||||
dependencies: StorageEventManagerBaseDependencies,
|
||||
watchEnabled?: boolean
|
||||
) {
|
||||
const adapter = new CLIStorageEventManagerAdapter(basePath);
|
||||
const adapter = new CLIStorageEventManagerAdapter(basePath, watchEnabled);
|
||||
super(adapter, dependencies);
|
||||
this.core = core;
|
||||
}
|
||||
@@ -25,4 +26,11 @@ export class StorageEventManagerCLI extends StorageEventManagerBase<CLIStorageEv
|
||||
// No-op in CLI version
|
||||
// Internal file handling is not needed
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the file watcher. Call this during graceful shutdown.
|
||||
*/
|
||||
close(): Promise<void> {
|
||||
return this.adapter.close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user