Added default globe.svg for invalid favicons
Some checks failed
Run Integration Tests / test (push) Failing after 41s
Some checks failed
Run Integration Tests / test (push) Failing after 41s
This commit is contained in:
parent
66414952e8
commit
5032173609
8 changed files with 118 additions and 51 deletions
14
favicon.go
14
favicon.go
|
@ -325,22 +325,22 @@ func findFaviconInHTML(pageURL string) string {
|
|||
|
||||
func getFaviconProxyURL(rawFavicon, pageURL string) string {
|
||||
if pageURL == "" {
|
||||
return "/static/images/missing.svg"
|
||||
return "/static/images/globe.svg"
|
||||
}
|
||||
|
||||
cacheID := faviconIDFromURL(pageURL)
|
||||
filename := fmt.Sprintf("%s_thumb.webp", cacheID)
|
||||
filename := fmt.Sprintf("%s_icon.webp", cacheID)
|
||||
cachedPath := filepath.Join(config.DriveCache.Path, "images", filename)
|
||||
|
||||
if _, err := os.Stat(cachedPath); err == nil {
|
||||
return fmt.Sprintf("/image/%s_thumb.webp", cacheID)
|
||||
return fmt.Sprintf("/image/%s_icon.webp", cacheID)
|
||||
}
|
||||
|
||||
// Resolve URL
|
||||
faviconURL, _ := resolveFaviconURL(rawFavicon, pageURL)
|
||||
if faviconURL == "" {
|
||||
recordInvalidImageID(cacheID)
|
||||
return "/static/images/missing.svg"
|
||||
return "/static/images/globe.svg"
|
||||
}
|
||||
|
||||
// Check if already downloading
|
||||
|
@ -361,10 +361,10 @@ func getFaviconProxyURL(rawFavicon, pageURL string) string {
|
|||
}
|
||||
}
|
||||
|
||||
return fmt.Sprintf("/image/%s_thumb.webp", cacheID)
|
||||
return fmt.Sprintf("/image/%s_icon.webp", cacheID)
|
||||
}
|
||||
|
||||
// Caches favicon, always saving *_thumb.webp
|
||||
// Caches favicon, always saving *_icon.webp
|
||||
func cacheFavicon(imageURL, imageID string) (string, bool, error) {
|
||||
// if imageURL == "" {
|
||||
// recordInvalidImageID(imageID)
|
||||
|
@ -374,7 +374,7 @@ func cacheFavicon(imageURL, imageID string) (string, bool, error) {
|
|||
// Debug
|
||||
fmt.Printf("Downloading favicon [%s] for ID [%s]\n", imageURL, imageID)
|
||||
|
||||
filename := fmt.Sprintf("%s_thumb.webp", imageID)
|
||||
filename := fmt.Sprintf("%s_icon.webp", imageID)
|
||||
imageCacheDir := filepath.Join(config.DriveCache.Path, "images")
|
||||
if err := os.MkdirAll(imageCacheDir, 0755); err != nil {
|
||||
return "", false, fmt.Errorf("couldn't create images folder: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue