mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-15 12:40:12 +00:00
Maintain watched file names for CLI collision checks
Share the CLI watcher with a reconciled name inventory, observe local mutations, and retain newer notifications across overlapping reads. Adopt the shared index for Obsidian and preserve fresh bulk operations.
This commit is contained in:
1 parent
78ebc2d298
commit
2a65fe0117
35 files changed
+5440
-28
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi, beforeEach } from "vitest";
|
||||
import type { IStorageEventWatchHandlers } from "@vrtmrz/livesync-commonlib/compat/managers/adapters";
|
||||
import type { CLIFileNameSource } from "@/apps/cli/storage/CLIFileNameSource";
|
||||
import type { NodeFile } from "@/apps/cli/adapters/NodeTypes";
|
||||
import { fs, os, path } from "@vrtmrz/livesync-commonlib/node";
|
||||
import { runtimeScopeDirectory } from "../runtimeState";
|
||||
@@ -86,6 +87,24 @@ describe("CLIStorageEventManagerAdapter", () => {
|
||||
expect(chokidar.watch).toHaveBeenCalledWith("/base", expect.objectContaining({ ignoreInitial: true }));
|
||||
});
|
||||
|
||||
it("borrows the prepared name source without starting a second watcher", async () => {
|
||||
const source = { beginWatch: vi.fn(), close: vi.fn() };
|
||||
const adapter = new CLIStorageEventManagerAdapter(
|
||||
"/base",
|
||||
undefined,
|
||||
true,
|
||||
undefined,
|
||||
undefined,
|
||||
source as unknown as CLIFileNameSource
|
||||
);
|
||||
const handlers = makeHandlers();
|
||||
await adapter.watch.beginWatch(handlers);
|
||||
expect(source.beginWatch).toHaveBeenCalledWith(handlers);
|
||||
expect(chokidar.watch).not.toHaveBeenCalled();
|
||||
await adapter.close();
|
||||
expect(source.close).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("add event produces NodeFile with correct relative path via onCreate", async () => {
|
||||
const basePath = "/vault/base";
|
||||
const adapter = new CLIStorageEventManagerAdapter(basePath, undefined, true);
|
||||
|
||||
Reference in new issue
Block a user