Skip to content

Commit 77cef1d

Browse files
Fixed metadata cache support in 1.8.3 and fixed resolved links using relative paths
1 parent d3a7eb7 commit 77cef1d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/@types/Obsidian.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ declare module "obsidian" {
3030
metadataCache: MetadataCacheMap
3131
resolvedLinks: ResolvedLinks
3232

33-
onCreateOrModify: (file: TFile) => void
33+
computeFileMetadataAsync: (file: TFile) => void
3434
saveFileCache: (filepath: string, cache: FileCacheEntry) => void
3535
linkResolver: () => void
3636
resolveLinks: (filepath: string) => void

src/patchers/metadata-cache-patcher.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class MetadataCachePatcher extends Patcher {
2323

2424
return next.call(this, filepath, ...args)
2525
},
26-
onCreateOrModify: (next: any) => async function (file: TFile, ...args: any[]) {
26+
computeFileMetadataAsync: (next: any) => async function (file: TFile, ...args: any[]) {
2727
// Call the original function if the file is not a canvas file
2828
if (PathHelper.extension(file.path) !== 'canvas')
2929
return next.call(this, file, ...args)
@@ -99,7 +99,10 @@ export default class MetadataCachePatcher extends Patcher {
9999

100100
// Update resolved links
101101
this.resolvedLinks[file.path] = [...fileNodesEmbeds, ...textNodesEmbeds, ...textNodesLinks].reduce((acc, cacheEntry) => {
102-
acc[cacheEntry.link] = (acc[cacheEntry.link] || 0) + 1
102+
const resolvedLinkpath = this.getFirstLinkpathDest(cacheEntry.link, file.path)
103+
if (!resolvedLinkpath) return acc
104+
105+
acc[resolvedLinkpath.path] = (acc[resolvedLinkpath.path] || 0) + 1
103106
return acc
104107
}, {} as Record<string, number>)
105108

0 commit comments

Comments
 (0)