summaryrefslogtreecommitdiff
path: root/brewcheck.go
diff options
context:
space:
mode:
Diffstat (limited to 'brewcheck.go')
-rw-r--r--brewcheck.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/brewcheck.go b/brewcheck.go
index ac34786..d550db4 100644
--- a/brewcheck.go
+++ b/brewcheck.go
@@ -17,10 +17,10 @@ func EnsureBrewAvailable() {
cache := filepath.Join(xdg.CacheHome, "wthis", "brew-checked")
// 1. check if cache file exists and is fresh
- if info, err := os.Stat(cache); err == nil {
- if time.Since(info.ModTime()) < TTL {
- return // recently verified that brew exists
- }
+ data, _ := os.ReadFile(cache)
+ t, _ := time.Parse(time.RFC3339, string(data))
+ if time.Since(t) < TTL {
+ return
}
// 2. otherwise, actually check
@@ -33,5 +33,5 @@ func EnsureBrewAvailable() {
// 3. write cache
_ = os.MkdirAll(filepath.Dir(cache), 0o755)
- _ = os.WriteFile(cache, []byte{}, 0o644)
+ _ = os.WriteFile(cache, []byte(time.Now().Format(time.RFC3339)), 0o644)
}