mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Use gallery updated at for cover mod time (#5225)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user