MCPcopy Create free account
hub / github.com/github/gh-aw / shouldRunUpdateCheckAtPath

Function shouldRunUpdateCheckAtPath

pkg/cli/update_check_state.go:29–56  ·  view source on GitHub ↗
(lastCheckFile string, interval time.Duration, label string, log *logger.Logger)

Source from the content-addressed store, hash-verified

27}
28
29func shouldRunUpdateCheckAtPath(lastCheckFile string, interval time.Duration, label string, log *logger.Logger) bool {
30 if lastCheckFile == "" {
31 log.Printf("Could not determine %s file path", label)
32 return false
33 }
34
35 data, err := os.ReadFile(lastCheckFile)
36 if err != nil {
37 if !os.IsNotExist(err) {
38 log.Printf("Error reading %s file: %v", label, err)
39 }
40 return true
41 }
42
43 lastCheck, err := time.Parse(time.RFC3339, strings.TrimSpace(string(data)))
44 if err != nil {
45 log.Printf("Error parsing %s time: %v", label, err)
46 return true
47 }
48
49 elapsed := time.Since(lastCheck)
50 if elapsed < interval {
51 log.Printf("Last %s was %v ago, skipping", label, elapsed)
52 return false
53 }
54
55 return true
56}
57
58func writeUpdateCheckTime(path string, perm os.FileMode, label string, log *logger.Logger) {
59 if path == "" {

Callers 2

shouldCheckForUpdateFunction · 0.85

Calls 1

PrintfMethod · 0.45

Tested by

no test coverage detected