mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
implement headless sync plugin
This commit is contained in:
@@ -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);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user