|
5 | 5 | "encoding/json" |
6 | 6 | "fmt" |
7 | 7 | "github.com/charmbracelet/log" |
| 8 | + "github.com/damongolding/immich-kiosk/internal/cache" |
8 | 9 | "github.com/damongolding/immich-kiosk/internal/common" |
9 | 10 | "github.com/damongolding/immich-kiosk/internal/config" |
10 | 11 | "github.com/damongolding/immich-kiosk/internal/immich" |
@@ -126,6 +127,15 @@ func getLatestRelease(owner, repo string) (string, string) { |
126 | 127 | url := fmt.Sprintf("https://api.github.com/repos/%s/%s/releases/latest", owner, repo) |
127 | 128 | link := fmt.Sprintf("https://github.com/%s/%s/releases/latest", owner, repo) |
128 | 129 |
|
| 130 | + if tagData, found := cache.Get(url); found { |
| 131 | + log.Debug("Github release cache hit", "url", url) |
| 132 | + tag, ok := tagData.(GitHubRelease) |
| 133 | + if ok { |
| 134 | + return tag.TagName, link |
| 135 | + } |
| 136 | + log.Debug("Github release cache data type assertion failed", "url", url) |
| 137 | + } |
| 138 | + |
129 | 139 | client := &http.Client{ |
130 | 140 | Timeout: 10 * time.Second, |
131 | 141 | } |
@@ -155,5 +165,7 @@ func getLatestRelease(owner, repo string) (string, string) { |
155 | 165 |
|
156 | 166 | link = fmt.Sprintf("https://github.com/%s/%s/releases/tag/%s", owner, repo, release.TagName) |
157 | 167 |
|
| 168 | + cache.Set(url, release) |
| 169 | + |
158 | 170 | return release.TagName, link |
159 | 171 | } |
0 commit comments