Use gallery updated at for cover mod time (#5225)

This commit is contained in:
WithoutPants
2024-09-05 16:45:15 +10:00
committed by GitHub
parent 2b288fd67c
commit ca970b9706
3 changed files with 56 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ import (
"net/http"
"os/exec"
"strconv"
"time"
"github.com/go-chi/chi/v5"
@@ -47,17 +48,21 @@ func (rs imageRoutes) Routes() chi.Router {
func (rs imageRoutes) Thumbnail(w http.ResponseWriter, r *http.Request) {
img := r.Context().Value(imageKey).(*models.Image)
rs.serveThumbnail(w, r, img)
rs.serveThumbnail(w, r, img, nil)
}
func (rs imageRoutes) serveThumbnail(w http.ResponseWriter, r *http.Request, img *models.Image) {
func (rs imageRoutes) serveThumbnail(w http.ResponseWriter, r *http.Request, img *models.Image, modTime *time.Time) {
mgr := manager.GetInstance()
filepath := mgr.Paths.Generated.GetThumbnailPath(img.Checksum, models.DefaultGthumbWidth)
// if the thumbnail doesn't exist, encode on the fly
exists, _ := fsutil.FileExists(filepath)
if exists {
utils.ServeStaticFile(w, r, filepath)
if modTime == nil {
utils.ServeStaticFile(w, r, filepath)
} else {
utils.ServeStaticFileModTime(w, r, filepath, *modTime)
}
} else {
const useDefault = true