MCPcopy Create free account
hub / github.com/UNLINEARITY/Obsidian-CodeSpace / installCachedReadOverride

Function installCachedReadOverride

src/native_pdf_export_patch.ts:516–544  ·  view source on GitHub ↗
(plugin: CodeSpacePlugin)

Source from the content-addressed store, hash-verified

514}
515
516function installCachedReadOverride(plugin: CodeSpacePlugin) {
517 const vault = plugin.app.vault as MutableVault;
518 const originalCachedRead = vault.cachedRead.bind(vault);
519
520 vault.cachedRead = async (file: TFile) => {
521 const session = activeNativeExportSession;
522 if (!session || file.path !== session.sourceFile.path) {
523 return await originalCachedRead(file);
524 }
525
526 session.cachedReadHits += 1;
527 debugNativePdf(session, "cachedRead intercepted for source file", {
528 file: file.path,
529 hit: session.cachedReadHits,
530 });
531 const activeView = plugin.app.workspace.getActiveViewOfType(MarkdownView) as MutableMarkdownView | null;
532 return await buildExpandedMarkdown(
533 plugin,
534 activeView,
535 session.sourceFile,
536 session.fallbackMarkdown
537 );
538 };
539
540 plugin.register(() => {
541 vault.cachedRead = originalCachedRead;
542 cleanupActiveNativeExportSession();
543 });
544}
545
546function installMarkdownViewPrintPatch(plugin: CodeSpacePlugin) {
547 const markdownViewProto = MarkdownView.prototype as MutableMarkdownView;

Callers 1

Calls 3

debugNativePdfFunction · 0.85
buildExpandedMarkdownFunction · 0.85

Tested by

no test coverage detected