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

Method updateTask

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

Source from the content-addressed store, hash-verified

179}
180
181func (e *Engine) updateTask(
182 ext ExternalTask,
183 mapped MappedTask,
184 extHash string,
185 ts TaskState,
186 state *SyncState,
187 now time.Time,
188) (SyncAction, error) {
189 action := SyncAction{
190 ExternalID: ext.ExternalID,
191 LocalID: ts.LocalID,
192 FilePath: ts.FilePath,
193 Title: ext.Title,
194 }
195
196 extChanged := extHash != ts.ExternalHash
197
198 localChanged, err := e.localFileChanged(ts)
199 if err != nil {
200 if os.IsNotExist(err) {
201 return e.recreateMissingFile(action, ext, mapped, extHash, ts, state, now)
202 }
203 return SyncAction{}, fmt.Errorf("failed to check local file: %w", err)
204 }
205
206 if !extChanged && !localChanged {
207 action.Reason = "skipped"
208 return action, nil
209 }
210
211 if localChanged {
212 return e.resolveConflict(action, ext, mapped, extHash, ts, state, now)
213 }
214
215 return e.applyExternalUpdate(action, ext, mapped, extHash, ts, state, now)
216}
217
218func (e *Engine) resolveConflict(
219 action SyncAction,

Callers 1

syncTaskMethod · 0.95

Calls 4

localFileChangedMethod · 0.95
recreateMissingFileMethod · 0.95
resolveConflictMethod · 0.95
applyExternalUpdateMethod · 0.95

Tested by

no test coverage detected