MCPcopy Create free account
hub / github.com/driangle/taskmd / applyExternalUpdate

Method applyExternalUpdate

apps/cli/internal/sync/engine.go:296–325  ·  view source on GitHub ↗
(
	action SyncAction,
	ext ExternalTask,
	mapped MappedTask,
	extHash string,
	ts TaskState,
	state *SyncState,
	now time.Time,
)

Source from the content-addressed store, hash-verified

294}
295
296func (e *Engine) applyExternalUpdate(
297 action SyncAction,
298 ext ExternalTask,
299 mapped MappedTask,
300 extHash string,
301 ts TaskState,
302 state *SyncState,
303 now time.Time,
304) (SyncAction, error) {
305 action.Reason = "updated"
306 if e.DryRun {
307 return action, nil
308 }
309
310 if err := UpdateSyncedTaskFile(ts.FilePath, mapped); err != nil {
311 return SyncAction{}, fmt.Errorf("failed to update task file: %w", err)
312 }
313
314 localHash, err := HashLocalFile(ts.FilePath)
315 if err != nil {
316 return SyncAction{}, fmt.Errorf("failed to hash updated file: %w", err)
317 }
318
319 ts.ExternalHash = extHash
320 ts.LocalHash = localHash
321 ts.LastSynced = now
322 state.Tasks[ext.ExternalID] = ts
323
324 return action, nil
325}
326
327func (e *Engine) localFileChanged(ts TaskState) (bool, error) {
328 currentHash, err := HashLocalFile(ts.FilePath)

Callers 2

updateTaskMethod · 0.95
resolveConflictMethod · 0.95

Calls 2

UpdateSyncedTaskFileFunction · 0.85
HashLocalFileFunction · 0.85

Tested by

no test coverage detected