更新缩略图
This commit is contained in:
@@ -38,7 +38,16 @@ func (h *ImageHandler) Serve(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
public, err := h.imageAccess.IsPublic(c.Request.Context(), rel)
|
||||
// A thumbnail shares its original's visibility, and old images without a
|
||||
// stored thumb fall back to the original object.
|
||||
origRel := rel
|
||||
if service.IsThumbKey(rel) {
|
||||
origRel = service.OrigKey(rel)
|
||||
} else if service.IsLastFrameKey(rel) {
|
||||
origRel = service.LastFrameOrigKey(rel)
|
||||
}
|
||||
|
||||
public, err := h.imageAccess.IsPublic(c.Request.Context(), origRel)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"detail": "failed to authorize image"})
|
||||
return
|
||||
@@ -65,6 +74,14 @@ func (h *ImageHandler) Serve(c *gin.Context) {
|
||||
c.JSON(http.StatusBadGateway, gin.H{"detail": "failed to fetch object"})
|
||||
return
|
||||
}
|
||||
if resp.StatusCode == http.StatusNotFound && origRel != rel {
|
||||
resp.Body.Close()
|
||||
resp, err = h.store.Get(c.Request.Context(), origRel, c.GetHeader("Range"))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadGateway, gin.H{"detail": "failed to fetch object"})
|
||||
return
|
||||
}
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
c.JSON(http.StatusNotFound, gin.H{"detail": "not found"})
|
||||
|
||||
Reference in New Issue
Block a user