MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / handleFileChanged

Method handleFileChanged

src/utils/DependencyCache.ts:140–180  ·  view source on GitHub ↗

* Handle file changes

(file: TFile, cache: unknown)

Source from the content-addressed store, hash-verified

138 * Handle file changes
139 */
140 private handleFileChanged(file: TFile, cache: unknown): void {
141 const before = this.getFileRelationshipSignature(file.path);
142
143 if (!this.isValidFile(file.path)) {
144 this.clearFileFromIndexes(file.path);
145 this.triggerIfFileRelationshipsChanged(file.path, before);
146 return;
147 }
148
149 const frontmatter = this.getFrontmatterFromCache(cache) ?? this.getFrontmatterForFile(file);
150 this.updateCompletionState(file.path, frontmatter);
151
152 if (!frontmatter) {
153 if (this.hasForwardRelationships(file.path)) {
154 this.clearForwardDependencies(file.path);
155 }
156 this.triggerIfFileRelationshipsChanged(file.path, before);
157 return;
158 }
159
160 if (!this.isTaskFileCallback(frontmatter)) {
161 if (this.hasForwardRelationships(file.path)) {
162 this.clearForwardDependencies(file.path);
163 }
164 this.triggerIfFileRelationshipsChanged(file.path, before);
165 return;
166 }
167
168 const nextFingerprint = this.buildRelationshipFingerprint(frontmatter);
169 if (this.relationshipFingerprints.get(file.path) === nextFingerprint) {
170 this.triggerIfFileRelationshipsChanged(file.path, before);
171 return;
172 }
173
174 // Re-index this task
175 // Only clear the forward dependencies (tasks this task depends on)
176 // Keep reverse dependencies intact - they'll be updated when other tasks change
177 this.clearForwardDependencies(file.path);
178 this.indexTaskFile(file.path, frontmatter);
179 this.triggerIfFileRelationshipsChanged(file.path, before);
180 }
181
182 private triggerIfFileRelationshipsChanged(path: string, before: string): void {
183 if (this.getFileRelationshipSignature(path) !== before) {

Callers 1

setupEventListenersMethod · 0.95

Calls 12

isValidFileMethod · 0.95
clearFileFromIndexesMethod · 0.95
getFrontmatterForFileMethod · 0.95
updateCompletionStateMethod · 0.95
indexTaskFileMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected