MetadataCache class provides access to cached metadata for files in the vault. It extends the Events class and emits events when file metadata changes.
Class Definition
Properties
Contains all resolved links. This object maps each source file’s path to an object of destination file paths with the link count. Source and destination paths are all vault absolute paths that comes from
TFile.path and can be used with Vault.getAbstractFileByPath(path).Contains all unresolved links. This object maps each source file to an object of unknown destinations with count. Source paths are all vault absolute paths, similar to
resolvedLinks.Methods
getFirstLinkpathDest
Available since version 0.12.5
The link path to resolve
The path of the source file containing the link
TFile | null - The resolved file or null if not found
getFileCache
Available since version 0.9.21
The file to get metadata for
CachedMetadata | null - The cached metadata or null if not available
getCache
Available since version 0.14.5
The vault path of the file
CachedMetadata | null - The cached metadata or null if not available
fileToLinktext
Generates a linktext for a file. If file name is unique, use the filename. If not unique, use full path.The file to generate linktext for
The path of the source file
Whether to omit the .md extension
string - The generated linktext
Events
changed
Called when a file has been indexed, and its (updated) cache is now available.This is not called when a file is renamed for performance reasons. You must hook the vault rename event for those.
The file that was indexed
The file’s content
The updated cached metadata
deleted
Called when a file has been deleted. A best-effort previous version of the cached metadata is presented, but it could be null in case the file was not successfully cached previously.The file that was deleted
The previous cached metadata, or null if not available
resolve
Called when a file has been resolved forresolvedLinks and unresolvedLinks. This happens sometimes after a file has been indexed.
The file that was resolved