* Synchronous task info getter (reads from metadataCache)
(path: string)
| 919 | * Synchronous task info getter (reads from metadataCache) |
| 920 | */ |
| 921 | getCachedTaskInfoSync(path: string): TaskInfo | null { |
| 922 | if (!this.isValidFile(path)) return null; |
| 923 | |
| 924 | const file = this.app.vault.getAbstractFileByPath(path); |
| 925 | if (!(file instanceof TFile)) return null; |
| 926 | |
| 927 | const pendingTaskInfo = this.getPendingTaskInfo(path); |
| 928 | const metadata = this.app.metadataCache.getFileCache(file); |
| 929 | if (!metadata?.frontmatter) { |
| 930 | return pendingTaskInfo; |
| 931 | } |
| 932 | |
| 933 | const metadataTaskInfo = this.isTaskFile(metadata.frontmatter) |
| 934 | ? this.extractTaskInfoFromNative(path, metadata.frontmatter) |
| 935 | : null; |
| 936 | if (pendingTaskInfo && this.shouldUsePendingTaskInfo(pendingTaskInfo, metadataTaskInfo)) { |
| 937 | return pendingTaskInfo; |
| 938 | } |
| 939 | |
| 940 | this.pendingTaskInfoByPath.delete(path); |
| 941 | return metadataTaskInfo; |
| 942 | } |
| 943 | |
| 944 | private async readFrontmatterFromFile(file: TFile): Promise<Record<string, unknown> | null> { |
| 945 | try { |
no test coverage detected