MCPcopy
hub / github.com/callumalpass/tasknotes / persistTaskInfoUpdates

Method persistTaskInfoUpdates

src/services/TaskService.ts:1060–1113  ·  view source on GitHub ↗
(
		task: TaskInfo,
		updates: Partial<TaskInfo>,
		operation: string
	)

Source from the content-addressed store, hash-verified

1058 }
1059
1060 private async persistTaskInfoUpdates(
1061 task: TaskInfo,
1062 updates: Partial<TaskInfo>,
1063 operation: string
1064 ): Promise<TaskInfo> {
1065 if (Object.keys(updates).length === 0) {
1066 return task;
1067 }
1068
1069 const file = this.plugin.app.vault.getAbstractFileByPath(task.path);
1070 if (!(file instanceof TFile)) {
1071 throw new Error(`Cannot find task file: ${task.path}`);
1072 }
1073
1074 const updatedTask: TaskInfo = { ...task, ...updates };
1075 await this.plugin.app.fileManager.processFrontMatter(file, (frontmatter) => {
1076 this.applyModelTaskUpdatesToFrontmatter(frontmatter, updates);
1077 });
1078
1079 try {
1080 if (this.plugin.cacheManager.waitForFreshTaskData) {
1081 await this.plugin.cacheManager.waitForFreshTaskData(file);
1082 }
1083 this.plugin.cacheManager.updateTaskInfoInCache(task.path, updatedTask);
1084 } catch (cacheError) {
1085 tasknotesLogger.error("Error updating cache for model task updates:", {
1086 category: "stale-data",
1087 operation: "persist-model-task-updates-cache",
1088 details: { taskPath: task.path, sourceOperation: operation },
1089 error: cacheError,
1090 });
1091 }
1092
1093 this.plugin.emitter.trigger(EVENT_TASK_UPDATED, {
1094 path: task.path,
1095 originalTask: task,
1096 updatedTask,
1097 });
1098
1099 if (this.plugin.taskCalendarSyncService?.isEnabled()) {
1100 this.plugin.taskCalendarSyncService
1101 .updateTaskInCalendar(updatedTask, task)
1102 .catch((error) => {
1103 tasknotesLogger.warn("Failed to sync model task update to Google Calendar:", {
1104 category: "provider",
1105 operation: "sync-model-task-update-google-calendar",
1106 details: { taskPath: task.path, sourceOperation: operation },
1107 error,
1108 });
1109 });
1110 }
1111
1112 return updatedTask;
1113 }
1114
1115 /**
1116 * Toggle the archive status of a task

Calls 10

getAbstractFileByPathMethod · 0.80
waitForFreshTaskDataMethod · 0.80
errorMethod · 0.80
warnMethod · 0.80
processFrontMatterMethod · 0.65
updateTaskInfoInCacheMethod · 0.65
triggerMethod · 0.65
isEnabledMethod · 0.65
updateTaskInCalendarMethod · 0.65

Tested by

no test coverage detected