MCPcopy
hub / github.com/dnote/dnote / shouldCheckUpdate

Function shouldCheckUpdate

pkg/cli/upgrade/upgrade.go:36–48  ·  view source on GitHub ↗

shouldCheckUpdate checks if update should be checked

(ctx context.DnoteCtx)

Source from the content-addressed store, hash-verified

34
35// shouldCheckUpdate checks if update should be checked
36func shouldCheckUpdate(ctx context.DnoteCtx) (bool, error) {
37 db := ctx.DB
38
39 var lastUpgrade int64
40 err := db.QueryRow("SELECT value FROM system WHERE key = ?", consts.SystemLastUpgrade).Scan(&lastUpgrade)
41 if err != nil {
42 return false, errors.Wrap(err, "getting last_udpate")
43 }
44
45 now := time.Now().Unix()
46
47 return now-lastUpgrade > upgradeInterval, nil
48}
49
50func touchLastUpgrade(ctx context.DnoteCtx) error {
51 db := ctx.DB

Callers 1

CheckFunction · 0.85

Calls 2

QueryRowMethod · 0.65
NowMethod · 0.65

Tested by

no test coverage detected