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

Function fullSyncBook

pkg/cli/cmd/sync/sync.go:496–516  ·  view source on GitHub ↗
(tx *database.DB, b client.SyncFragBook)

Source from the content-addressed store, hash-verified

494}
495
496func fullSyncBook(tx *database.DB, b client.SyncFragBook) error {
497 var localUSN int
498 var dirty bool
499 err := tx.QueryRow("SELECT usn, dirty FROM books WHERE uuid = ?", b.UUID).Scan(&localUSN, &dirty)
500 if err != nil && err != sql.ErrNoRows {
501 return errors.Wrapf(err, "getting local book %s", b.UUID)
502 }
503
504 // if book exists in the server and does not exist in the client
505 if err == sql.ErrNoRows {
506 if e := mergeBook(tx, b, modeInsert); e != nil {
507 return errors.Wrapf(e, "resolving book")
508 }
509 } else if b.USN > localUSN {
510 if e := mergeBook(tx, b, modeUpdate); e != nil {
511 return errors.Wrapf(e, "resolving book")
512 }
513 }
514
515 return nil
516}
517
518// checkNoteInList checks if the given syncList contains the note with the given uuid
519func checkNoteInList(uuid string, list *syncList) bool {

Callers 3

fullSyncFunction · 0.85
TestFullSyncBookFunction · 0.85
TestStepSyncBookFunction · 0.85

Calls 2

mergeBookFunction · 0.85
QueryRowMethod · 0.65

Tested by 2

TestFullSyncBookFunction · 0.68
TestStepSyncBookFunction · 0.68