4 Commits

4 changed files with 18 additions and 2 deletions

View File

@@ -31,6 +31,10 @@ dokku storage:mount teafolio /srv/teafolio-dokku/config.toml:/app/config.toml
## CHANGELOG
2022-12-31 v1.3.1
- Fix missing images on homepage
- Fix an issue with wrong mtime comparisons for updated repositories
2022-12-31 v1.3.0
- Add `OverrideOrder` configuration option to insert repos at specific positions
- Cache target image URLs to improve homepage load performance

View File

@@ -36,6 +36,7 @@ type Application struct {
reposMut sync.RWMutex
reposCache []gitea.Repo // Sorted by recently-created-first
reposCacheByName map[string]int
reposAlphabeticalOrder map[string]int
}

View File

@@ -9,7 +9,7 @@ func (this *Application) Bannerpage(w http.ResponseWriter, r *http.Request, repo
this.reposMut.RLock()
defer this.reposMut.RUnlock()
ridx, ok := this.reposAlphabeticalOrder[repoName]
ridx, ok := this.reposCacheByName[repoName]
if !ok {
w.Header().Set(`Location`, `/static/no_image.png`)
w.WriteHeader(301)

13
sync.go
View File

@@ -94,7 +94,7 @@ func (this *Application) sync(ctx context.Context) (bool, error) {
}
for i, rr := range repos {
if idx, ok := this.reposAlphabeticalOrder[rr.Name]; ok && this.reposCache[idx].GiteaUpdated == rr.GiteaUpdated {
if idx, ok := this.reposCacheByName[rr.Name]; ok && this.reposCache[idx].GiteaUpdated == rr.GiteaUpdated {
// Already exists in cache with same Gitea update time
// Copy timestamps
repos[i] = this.reposCache[idx]
@@ -117,6 +117,11 @@ func (this *Application) sync(ctx context.Context) (bool, error) {
log.Printf("loading topics for '%s': %s", rr.Name, err)
}
err = this.gitea.PopulateImages(ctx, &rr)
if err != nil {
log.Printf("loading images for '%s': %s", rr.Name, err)
}
// Save
repos[i] = rr
}
@@ -151,9 +156,15 @@ func (this *Application) sync(ctx context.Context) (bool, error) {
repos = reordered
}
reposCacheByName := make(map[string]int, len(repos))
for idx, repo := range repos {
reposCacheByName[repo.Name] = idx
}
// Commit our changes for the other threads to look at
this.reposMut.Lock()
this.reposCache = repos
this.reposCacheByName = reposCacheByName
this.reposAlphabeticalOrder = alphabeticalOrderIndexes
this.reposMut.Unlock()