MCPcopy Index your code
hub / github.com/dnote/dnote / syncDeleteNote

Function syncDeleteNote

pkg/cli/cmd/sync/sync.go:412–434  ·  view source on GitHub ↗
(tx *database.DB, noteUUID string)

Source from the content-addressed store, hash-verified

410}
411
412func syncDeleteNote(tx *database.DB, noteUUID string) error {
413 var localUSN int
414 var dirty bool
415 err := tx.QueryRow("SELECT usn, dirty FROM notes WHERE uuid = ?", noteUUID).Scan(&localUSN, &dirty)
416 if err != nil && err != sql.ErrNoRows {
417 return errors.Wrapf(err, "getting local note %s", noteUUID)
418 }
419
420 // if note does not exist on client, noop
421 if err == sql.ErrNoRows {
422 return nil
423 }
424
425 // if local copy is not dirty, delete
426 if !dirty {
427 _, err = tx.Exec("DELETE FROM notes WHERE uuid = ?", noteUUID)
428 if err != nil {
429 return errors.Wrapf(err, "deleting local note %s", noteUUID)
430 }
431 }
432
433 return nil
434}
435
436// checkNotesPristine checks that none of the notes in the given book are dirty
437func checkNotesPristine(tx *database.DB, bookUUID string) (bool, error) {

Callers 3

fullSyncFunction · 0.85
stepSyncFunction · 0.85
TestSyncDeleteNoteFunction · 0.85

Calls 2

QueryRowMethod · 0.65
ExecMethod · 0.65

Tested by 1

TestSyncDeleteNoteFunction · 0.68