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

Function sendChanges

pkg/cli/cmd/sync/sync.go:1004–1029  ·  view source on GitHub ↗
(ctx context.DnoteCtx, tx *database.DB)

Source from the content-addressed store, hash-verified

1002}
1003
1004func sendChanges(ctx context.DnoteCtx, tx *database.DB) (bool, error) {
1005 log.Info("sending changes.")
1006
1007 var delta int
1008 err := tx.QueryRow("SELECT (SELECT count(*) FROM notes WHERE dirty) + (SELECT count(*) FROM books WHERE dirty)").Scan(&delta)
1009
1010 fmt.Printf(" (total %d).", delta)
1011
1012 log.DebugNewline()
1013
1014 behind1, err := sendBooks(ctx, tx)
1015 if err != nil {
1016 return behind1, errors.Wrap(err, "sending books")
1017 }
1018
1019 behind2, err := sendNotes(ctx, tx)
1020 if err != nil {
1021 return behind2, errors.Wrap(err, "sending notes")
1022 }
1023
1024 fmt.Println(" done.")
1025
1026 isBehind := behind1 || behind2
1027
1028 return isBehind, nil
1029}
1030
1031func updateLastMaxUSN(tx *database.DB, val int) error {
1032 if err := database.UpdateSystem(tx, consts.SystemLastMaxUSN, val); err != nil {

Callers 1

newRunFunction · 0.85

Calls 5

InfoFunction · 0.92
DebugNewlineFunction · 0.92
sendBooksFunction · 0.85
sendNotesFunction · 0.85
QueryRowMethod · 0.65

Tested by

no test coverage detected