MCPcopy
hub / github.com/dnote/dnote / Check

Function Check

pkg/cli/upgrade/upgrade.go:111–145  ·  view source on GitHub ↗

Check triggers update if needed

(ctx context.DnoteCtx)

Source from the content-addressed store, hash-verified

109
110// Check triggers update if needed
111func Check(ctx context.DnoteCtx) error {
112 // If upgrade check is not enabled, do not proceed further
113 if !ctx.EnableUpgradeCheck {
114 return nil
115 }
116
117 shouldCheck, err := shouldCheckUpdate(ctx)
118 if err != nil {
119 return errors.Wrap(err, "checking if dnote should check update")
120 }
121 if !shouldCheck {
122 return nil
123 }
124
125 err = touchLastUpgrade(ctx)
126 if err != nil {
127 return errors.Wrap(err, "updating the last upgrade timestamp")
128 }
129
130 fmt.Printf("\n")
131 willCheck, err := ui.Confirm("check for upgrade?", true)
132 if err != nil {
133 return errors.Wrap(err, "getting user confirmation")
134 }
135 if !willCheck {
136 return nil
137 }
138
139 err = checkVersion(ctx)
140 if err != nil {
141 return errors.Wrap(err, "checking version")
142 }
143
144 return nil
145}

Callers 2

newRunFunction · 0.92
newRunFunction · 0.92

Calls 4

ConfirmFunction · 0.92
shouldCheckUpdateFunction · 0.85
touchLastUpgradeFunction · 0.85
checkVersionFunction · 0.85

Tested by

no test coverage detected