implement headless sync plugin

This commit is contained in:
Nystik
2026-03-29 00:26:41 +01:00
parent acb700a82b
commit 90d9512f18
10 changed files with 1026 additions and 8 deletions

View File

@@ -49,4 +49,20 @@ export const fsShim = {
metadataCache.populate(tree);
console.log(`[shim:fs] Initialized with ${metadataCache.size} entries`);
},
async _refreshSubtree(subPath) {
const tree = await transport.fetchTree(subPath);
const prefix = subPath.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\/+$/, "");
// Tree keys are relative to subPath, so prefix them to make vault-relative
const prefixed = {};
prefixed[prefix] = { type: "directory" };
for (const [key, meta] of Object.entries(tree)) {
prefixed[prefix + "/" + key] = meta;
}
metadataCache.merge(prefixed);
},
};

View File

@@ -82,6 +82,13 @@ export class MetadataCache {
return results;
}
// Merge entries from a subtree without clearing existing data
merge(tree) {
for (const [path, meta] of Object.entries(tree)) {
this._entries.set(this._normalize(path), meta);
}
}
get size() {
return this._entries.size;
}